Re: Detecting socket is closed
Re: Detecting socket is closed
- Subject: Re: Detecting socket is closed
- From: james woodyatt <email@hidden>
- Date: Wed, 5 Jul 2006 10:55:46 -0700
On Jul 5, 2006, at 10:16, Mark Thomas wrote:
Is there a way to tell that a socket has been closed ?, as I’m
seeing if I
try writing to socket which has been closed down it will crash out
causing a
SIGPIPE. I thought something in ioctl would help for this but
nothing seems
obvious from looking at man and headers files
I using a socket in tcp mode if that helps.
There are two ways that TCP sockets can be closed by the remote peer.
When the peer initiates an orderly close, it will send its last octet
in a FIN packet. After the last octet is delivered by your socket,
subsequent calls to read or recv will return zero. That's how you
will know that the receive side of your TCP socket has been closed
while the write side remains open.
When the peer initiates an abortive close, it will send a RST
packet. After the RST packet is received at your socket, subsequent
calls to read or recv will return ECONNRESET, and attempts to write
will raise SIGPIPE. (If SIGPIPE is ignored by the process signal
mask, then write or send will return EPIPE.)
--
james woodyatt <email@hidden>
member of technical staff
apple computer, inc.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden