![]() |
|
Winsock non-blocking recv |
Billybob
Member #3,136
January 2003
|
I want to be able to receive data from a socket if and only if it is available. If none is available I don't want it to wait for some, I want to continue with the rest of my program. I believe this is called non-blocking. How would I go about doing that? It looks like select will tell be if there is data to read (or connections to accept, for listening sockets). But it has this timeout thing...I don't really want it to stop for any amount of time (beyond checking for data). Any help?
|
Oscar Giner
Member #2,207
April 2002
![]() |
Quote: But it has this timeout thing...I don't really want it to stop for any amount of time
Pass 0 as timeout and it won't wait if there's no data -- |
Billybob
Member #3,136
January 2003
|
MSDN said: Quote: Set the timeout parameter to null for blocking operations. ?
|
Oscar Giner
Member #2,207
April 2002
![]() |
I have this and it works (and it doesn't block)
Notice that the timeout parameter is a pointer. What the docs say is that if you pass a NULL pointer the operation is blocking. -- |
Billybob
Member #3,136
January 2003
|
You're the best Oscar
|
|