Jump to content
  • Advertisement
Sign in to follow this  
gamelife

SDL_net non-blocking?

This topic is 2377 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 -> Download Sourcecode

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!