Jump to content
  • Advertisement
Sign in to follow this  
Tessellator

Select() with a small timeout VS non-blocking sockets

This topic is 4343 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

This is a question out of curiosity more than anything else. Because windows doesn't implement the fcntl() function (and I didn't know about the ioctlsocket() function to do the same) I simply did a select() with a timeout of 1 microsecond which seemed to work fine. Are there any benifits to using blocking sockets with a really small timeout on select() calls like this? Or is it better to make them non-blocking and just poll recv() etc rather than select()? I'm quite a newbie in this area, but I decided to learn a bit after 3d coding at home started to become a bit dull :). T

Share this post


Link to post
Share on other sites
Advertisement
After simple benchmarking, I found that non-blocking sockets were slightly faster than blocking sockets with select(), though the difference won't likely make a difference in a game application. If you use select(), set the timeout to 0 (no need to waste even 1us if no data is ready).

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!