• Advertisement
Sign in to follow this  

SDL_net non-blocking?

This topic is 2192 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is it possible to set SDL_net sockets to non-blocking, i.e. ensure SDLNet_TCP_Send and SDLNet_TCP_Recv to return immediately? According to the docs, these functions will send/recv data of exactly number of bytes given. SDLNet_CheckSockets only check sockets for activity, so i guess it doesn't help.

Share this post


Link to post
Share on other sites
Advertisement
As I understand it, the answer is no. You could make it act like a non-blocking call by sticking it in its own thread and talking to it via a queue, though.

Share this post


Link to post
Share on other sites
I know this is like 5 years laters, but anyone reading this now is probably looking for non-blocking SDL_net TCP/IP code, so i'm posting a link here with some fast simple beginner code that works.

So, the answer is: Yes it's possible! And you don't even have to use threads.

Click -> [url="http://dream-code.se/sdl_tutorials/sdl_net/SDLNet_NonBlockingTCP.zip"]Download Sourcecode[/url]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement