I've got a few TcpSockets and a TcpListener in a selector. Why does this happen:
if (selector.isReady(client))
{
// The client has sent some data, we can receive it
std::cout << "Is ready\n";//Shows
sf::Packet packet;
int Status = client.receive(packet);
std::cout << "Status: " << Status << '\n';//Displays 1, aka Socket::NotReady
if (Status == sf::Socket::Done)
{
std::cout << "Message recieved!\n"; //Never happens
}
}
Shouldn't these values be the same? I'm using the SocketSelector example in the SFML 2.0 documentation. I am also using the latest git snapshot of SFML. One final thing: both the listener and all TcpSockets are NOT blocking.
Yeah, I suppose that makes sense. I would like to mention though, that using the method from above does not work, but the other version does. I mean:
receive (void *data, std::size_t size, std::size_t &received)
Works properly, whereas
receive (Packet &packet)
does not, with the exact same code. Maybe if you have time to test your example on the documentation (http://www.sfml-dev.org/documentation/2.0/classsf_1_1SocketSelector.php (http://www.sfml-dev.org/documentation/2.0/classsf_1_1SocketSelector.php)) you can see what I mean. the given example does not work with the packet version.