Timeout for SDLNet_TCP_Recv?

483 views Asked by At

Is there any way to cancel a SDLNet_TCP_Recv call after some time when no answer arrives? Or are there alternatives to this function that support a timeout option?

1

There are 1 answers

9
genpfault On BEST ANSWER

Create a socket set with SDLNet_AllocSocketSet() & add your TCPsocket to it with SDLNet_AddSocket(). Then you can use SDLNet_CheckSockets() with a timeout to wait for network activity.

Depending on the return-value you can then use SDLNet_SocketReady() to verify that the SDLNet_TCP_Recv() call won't block.