Non-blocking winsock questions
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?
Isn''t ioctl() used to set socket properties?
And uhhhhh, non-blocking sockets won''t block on recv. That''s the whole point. It returns 10035 (WSAEWOULDBLOCK).
And uhhhhh, non-blocking sockets won''t block on recv. That''s the whole point. It returns 10035 (WSAEWOULDBLOCK).
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?
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?
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]
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]
What do you mean ''as a stream''? I wait for enough data for the packet header then read the data as it comes in
This isn''t for a game too, its like a proxy server
This isn''t for a game too, its like a proxy server
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement