Re: How can I tell when a remote TCP connection is closed?
- From: "Phil Frisbie, Jr." <phil@xxxxxxxxxxxx>
- Date: Wed, 10 Aug 2005 14:42:08 -0700
Jim H wrote:
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.
select() on readable WILL return true if the server has closed the TCP connection gracefully, so perhaps you have something else wrong with your code?
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.
After select() returns true for readable, then the recv() will fail with the error. That is the ONLY way to do it.
Can anyone help me out with this?>
Thanks in advance,
jim
-- Phil Frisbie, Jr. Hawk Software http://www.hawksoft.com .
- Follow-Ups:
- Re: How can I tell when a remote TCP connection is closed?
- From: Alexander Nickolov
- Re: How can I tell when a remote TCP connection is closed?
- References:
- Prev by Date: Re: iProvisioningProfileWireless XML sample?
- Next by Date: Re: getaddrinfo() in MFC app
- Previous by thread: 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
|