SFML community forums

Help => Network => Topic started by: Zoomulator on October 13, 2010, 11:14:44 pm

Title: How to handle Non-blocking TCP socket returning notready
Post by: Zoomulator on October 13, 2010, 11:14:44 pm
I've set up a selector in the fashion stated in the tutorial though with non-blocking sockets. Occasionally, the receiving TCP socket will return "not ready" and then simply drop the packet.
It tries to read the socket twice and returns "Not ready" both times, and then it just stops trying so the packet is never received. The next packet may arrive properly as this only happens rarely.

What should I do when a TCP socket returns "not ready"? Should I put it in a special buffer that tries to read it again each iteration until it succeeds? What then if it doesn't succeed before another message arrives and is successfully received by the selector algorithm?
Title: How to handle Non-blocking TCP socket returning notready
Post by: Laurent on October 13, 2010, 11:46:43 pm
You shouldn't use non-blocking sockets in a selector. It doesn't make sense, non-blocking sockets are supposed to be polled.
Title: How to handle Non-blocking TCP socket returning notready
Post by: Zoomulator on October 13, 2010, 11:49:05 pm
I'm generally nonsensical =D

So when a selector says a socket is ready to receive, does it already have all data or is there still communications in the connection that could possibly delay the blocking?
Title: How to handle Non-blocking TCP socket returning notready
Post by: Laurent on October 14, 2010, 08:03:56 am
Quote
So when a selector says a socket is ready to receive, does it already have all data or is there still communications in the connection that could possibly delay the blocking?

When the selector says a socket is ready, you can immediately call Receive and get data from it.
Title: How to handle Non-blocking TCP socket returning notready
Post by: Zoomulator on October 14, 2010, 12:23:47 pm
Thanks Laurent!
Your support is impeccable!