Re: how to avoid recv() blocking issue?



That strange because WSAEventSelect() as WSAAsyncSelect do set socket as
non-blocked. Check that you if you used them or through
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 and
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 using
TerminateThread() - btw, it's not a good idea, because a socket remains
"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.



.



Relevant Pages

  • Re: how to avoid recv() blocking issue?
    ... now, if any data reading happens, i.e. recv() receives something, NewEvent ... alex c. ... there's a thread to receive data from a server. ... WSAEventSelect() does not ...
    (microsoft.public.win32.programmer.networks)
  • Re: how to avoid recv() blocking issue?
    ... You need to try recv() when event happen only and check that socket you use ... WSAEventSelect() is used to fire windows events, ... there's a thread to receive data from a server. ...
    (microsoft.public.win32.programmer.networks)
  • Re: how to avoid recv() blocking issue?
    ... WSAEventSelect() is used to fire windows events, ... WSAEVENT NewEvent = WSACreateEvent; ... now, if any data reading happens, i.e. recv() receives something, NewEvent ... socket will store it in the buffer you gave to receive and assert the event. ...
    (microsoft.public.win32.programmer.networks)
  • Re: how to avoid recv() blocking issue?
    ... using WSAEventSelect. ... we have a weak link in a chain: a timeout. ... drop the connection abnormally such that the blocking recv will never ... TerminateThread- btw, it's not a good idea, because a socket ...
    (microsoft.public.win32.programmer.networks)