Re: Connection broken on recv() function



"Kwokho" <kwokho74@xxxxxxxxxxx> wrote in message news:eoGM6LQuFHA.992
@TK2MSFTNGP12.phx.gbl...
> >> I use recv() function to receive data from the client socket (blocked).
> >> If
> >> the client has terminated the process, the function returns SOCKET_ERROR
> >> with the error code WSAECONNRESET(10054). Then I can handle this error by
> >> determinating the error code.
> >>
> >> However, when I unplug the LAN cable on the client's computer, the
> >> function
> >> does not return, it still blocked in the recv() function. Is there any
> >> way
> >> to set the recv() function return immediately or within a certain time?
> >> And
> >> I don't want to use a nonblock socket.

I believe this behave may depend on network card and/or driver.
On my system (W2K) whenever I unplug the cable:
a) Network indicator in the tray changes to "cable unplugged"
b) All applications that uses sockets disconnects immediately

For example ICQ 2003 need some time to determine when internet
connection is gone, when there is problem with the traffic. However,
whenever cable is unplugged, it reports connection loss right away.
.



Relevant Pages

  • Re: Connection broken on recv() function
    ... > I use recv() function to receive data from the client socket. ... > with the error code WSAECONNRESET. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Connection broken on recv() function
    ... >> I use recv() function to receive data from the client socket. ... >> with the error code WSAECONNRESET. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Connection broken on recv() function
    ... Set a receive timeout on your socket. ... > I use recv() function to receive data from the client socket. ... > with the error code WSAECONNRESET. ...
    (microsoft.public.win32.programmer.networks)
  • Re: Connection broken on recv() function
    ... Arkady ... > all your recv calls... ... >>> with the error code WSAECONNRESET. ... >>> I don't want to use a nonblock socket. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: recv on blocking sockets
    ... I would do a selecton the socket to check it for "readability" with a reasonable timeout. ... two hours and the “cable unplug timeout”, in the range of 10 minutes. ... What shall I do to get recv return in a timely fashion ...
    (microsoft.public.windowsce.app.development)