Skip to main content
GameDev.net gamedev.net
🔒 Locked

SDL_net non-blocking?

Started by gamelife Jun 11, 2007 at 3:12 AM 1 replies 4.3k views
Original Post
gamelife
gamelife
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.
Ozymandias43
Ozymandias43
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.
solarstrings
solarstrings
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 -> Download Sourcecode

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.