• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Detecting socket is closed
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Detecting socket is closed (From: Mark Thomas <email@hidden>)

  • Prev by Date: Re: Detecting socket is closed
  • Next by Date: Hanging Sockets
  • Previous by thread: Re: Detecting socket is closed
  • Next by thread: Hanging Sockets
  • Index(es):
    • Date
    • Thread