Re: How can I tell when a remote TCP connection is closed?
- From: "Jim H" <jimh@xxxxxxxxxxxxx>
- Date: Fri, 12 Aug 2005 16:44:37 -0400
Thanks for the replies. I'm using select to see if a socket is readable and
calling recv to see if it returns 0. Recv only returns zero if the peer has
gracefully shut the connection down. My problem is non-graceful
disconnects. I'm getting times where my recv returns a byte but when I go
to write to the socket and I get an broken pipe error. How do I detect non
graceful disconnects? Will exception fds passed to select be set int these
instances? I'm putting the code in to try it but I have to wait for a
broken pipe to happen, so if someone knows the answer I'd appreciate it.
Thanks in advance,
jim
"Jim H" <jimh@xxxxxxxxxxxxx> wrote in message
news:ObYSn0enFHA.576@xxxxxxxxxxxxxxxxxxxxxxx
>I have a client with a TCP connection to a server. Without using events (I
>need the code to be portable), is there a way that I can tell if the remote
>end has closed the connection without performing a read or a write on the
>socket? I tried doing a select for an error condition but it times out.
>Select on readable or writeable always return as if the remote end is still
>connected.
>
> The remote end is doing a shutdown and close on the socket. Netstat shows
> close_wait. I need to know if the connection has been dropped without
> having a read or write fail.
>
> Can anyone help me out with this?
>
> Thanks in advance,
> jim
>
.
- Follow-Ups:
- Re: How can I tell when a remote TCP connection is closed?
- From: Phil Frisbie, Jr.
- Re: How can I tell when a remote TCP connection is closed?
- References:
- Prev by Date: Re: Bandwidth detection
- Next by Date: Re: How can I tell when a remote TCP connection is closed?
- Previous by thread: Re: How can I tell when a remote TCP connection is closed?
- Next by thread: Re: How can I tell when a remote TCP connection is closed?
- Index(es):
Relevant Pages
|