Re: how to avoid recv() blocking issue?
- From: "Michael K. O'Neill" <MikeAThon2000@xxxxxxxxxxxxxxxxxx>
- Date: Tue, 7 Nov 2006 16:57:13 -0800
"Chris Becke" <chris.becke@xxxxxxxxx> wrote in message
news:O1wISQkAHHA.4292@xxxxxxxxxxxxxxxxxxxxxxx
It is possible to be stuck in a blocking call to recv, and for the serverto
drop the connection abnormally such that the blocking recv will neverexit.
I really dont see how that is happening in this situation.the
However, because of that possibility, all my calls to blocking recv use
basic code:
first, use ioctlsocket(s,FIONREAD,&cbRead); to check if there is data
available.
If there is, go straight to recv, otherwise call
select(0,fd_s,0,0,&tv_timeout); with a timeout.
Use of FIONREAD, to determine whether there is data to read as a prelude to
a call to recv(), is part of the Winsock "Lame List" and should be avoided.
If one thread is stuck inside a blocking call to recv(), then one way to get
out of it is to call closesocket() from a second thread. This will cause
recv() in the first thread to return immediately, with a return value of
zero (indicating that the connection was closed).
.
- Follow-Ups:
- Re: how to avoid recv() blocking issue?
- From: Alexander Nickolov
- Re: how to avoid recv() blocking issue?
- References:
- how to avoid recv() blocking issue?
- From: Alexander Cherny
- Re: how to avoid recv() blocking issue?
- From: Arkady Frenkel
- Re: how to avoid recv() blocking issue?
- From: Chris Becke
- how to avoid recv() blocking issue?
- Prev by Date: Re: How to specify which network connection to be use for diff apps?
- Next by Date: Re: how to avoid recv() blocking issue?
- Previous by thread: Re: how to avoid recv() blocking issue?
- Next by thread: Re: how to avoid recv() blocking issue?
- Index(es):
Relevant Pages
|