Archived

This topic is now archived and is closed to further replies.

Non-blocking winsock questions

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

Could I use the iocrtl function to check for data instead of select??? That is all select does and makes the code cumbersome using those FD lists Also will recv still block if there is no data available?

Share this post


Link to post
Share on other sites
It can also get the number of bytes available to read. I use this already to make sure I have enough data to read a whole packet

The only thing I am doing for a non blocking server is using select, could I check for data myself instead of using those awful FD lists?

Share this post


Link to post
Share on other sites
Peeking like that won't work as soon as you have packets of different sizes, so I wouldn't use peeking at all. It basically tells you how many bytes are in the incoming buffer, right? Bite the bullet and read in data as a stream (because it is a stream to begin with) and organize it into packets as it comes in. When there's enough data (according to your packet header), you have a complete packet. Takes more work to implement that, but it's infinitely more flexible.

As for select, well I'm using non-blocking sockets too and the only use I have for select is to check how the non-blocking connect() returned.

[edited by - foofightr on August 14, 2003 9:06:05 PM]

Share this post


Link to post
Share on other sites