Hello everybody.
I'm using SFML 2.0 RC and I have this code, but doesn't wait doesn't work.
sf::SocketSelector selector;
sf::UdpSocket socket;
selector.add(socket);
sf::Packet p;
p << 10; //arbitrary data
socket.send(p,sf::IpAddress::getLocalAddress(),1010);
selector.wait(sf::seconds(10)); //should wait 10 seconds
if(selector.isReady(socket))
{
sf::IpAddress ip;
uint16 port;
if(socket.receive(p,ip,port) == sf::Socket::Done)
{
printf("Receive data\n");
}
}
else
{
printf("Not ready\n");
}
Some time ago using BSD Socket and WinSock and it worked. And not because it does not work if it should be like
Greetings!
#include <cstdlib>
#include <SFML/Network.hpp>
int main(int argc, char **argv)
{
sf::SocketSelector selector;
sf::UdpSocket socket;
sf::Packet p;
p << 10; //arbitrary data
if(socket.bind(3030) != sf::Socket::Done)
{
printf(":C no bind");
}
selector.add(socket);
socket.send(p,sf::IpAddress::getLocalAddress(),4030); //if remove this line, the program wait 10 seconds
//socket.send(p,sf::IpAddress("192.168.1.31"),4040); //or use this line works!
printf("...");
selector.wait(sf::seconds(10)); //should wait 10 seconds
printf("...\n");
if(selector.isReady(socket))
{
sf::IpAddress ip;
uint16 port;
if(socket.receive(p,ip,port) == sf::Socket::Done)
{
printf("Receive data\n");
}
else
{
printf("None\n");
}
}
else
{
printf("Not ready\n");
}
system("pause");
}
This is a minimal code
Edit:Don't worry I will use the old implementation for this (with WinSock)
Thanks you!