Re: how to avoid recv() blocking issue?
- From: "Chris Becke" <chris.becke@xxxxxxxxx>
- Date: Wed, 8 Nov 2006 09:12:36 +0200
when the non blocking socket is setup in blocking mode... I did specify
blocking socket.
With a non blocking socket, yeah, i dont know if any situation that would
make it block.
"Alexander Nickolov" <agnickolov@xxxxxxxx> wrote in message
news:u7VgazrAHHA.1780@xxxxxxxxxxxxxxxxxxxxxxx
Can you post the circumstances? I've never heard beforeserver
of a socket in non-blocking mode blocking in recv, at
least on a machine without third-party LSPs (all bets are
off if one has a third party LSP...).
Besides, it's not recommended even by Microsoft to ever
check the socket explicitly for data availablity! That
constitutes poor performance.
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnickolov@xxxxxxxx
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================
"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
asto
drop the connection abnormally such that the blocking recv will never
exit.
I really dont see how that is happening in this situation.
However, because of that possibility, all my calls to blocking recv use
the
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.
"Arkady Frenkel" <arkadyf@xxxxxxxxxxxxxxxx> wrote in message
news:esLEwWjAHHA.2140@xxxxxxxxxxxxxxxxxxxxxxx
That strange because WSAEventSelect() as WSAAsyncSelect do set socket
usingnon-blocked. Check that you if you used them or throughand
ioctlsocket() with FIONBIO set to 1 on recv() you have to return with
WSAWOULDBLOCK warning or data
Arkady
"Alexander Cherny" <black@xxxxxxxxxxxxxxx> wrote in message
news:%23Wyf0XfAHHA.4292@xxxxxxxxxxxxxxxxxxxxxxx
hi all,
i got a problem with recv().
there's a thread to receive data from a server. periodically this
thread
has to stop (to let others to do some work). i created some events to
check them inside the thread. the problem happens, when recv() starts
does not receive any data from a server. this time the thread is
stuck -
recv() just waits for data, and i can't stop the thread well (not
remainsTerminateThread() - btw, it's not a good idea, because a socket
"anchored" by the thread).
is there any way to "unblock" recv() somehow? WSAEventSelect() does
not
help. looks like it's for different purposes.
thanks a lot.
--
alex c.
.
- 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
- Re: how to avoid recv() blocking issue?
- From: Alexander Nickolov
- how to avoid recv() blocking issue?
- Prev by Date: Re: how to avoid recv() blocking issue?
- Next by Date: Re: How to specify which network connection to be use for diff apps?
- Previous by thread: Re: how to avoid recv() blocking issue?
- Next by thread: Re: how to avoid recv() blocking issue?
- Index(es):
Relevant Pages
|