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

Started by
1 comment, last by Tessellator 17 years, 9 months ago
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
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).
Cool, thanks for that. Non-blocking it is then :).

Cheers,
T

This topic is closed to new replies.

Advertisement