Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!udel!rochester!bbn.com!fkittred From: fkittred@bbn.com (Fletcher Kittredge) Newsgroups: comp.unix.programmer Subject: Re: Detecting Closed Sockets Message-ID: <63357@bbn.BBN.COM> Date: 21 Mar 91 19:10:21 GMT References: <39989@cup.portal.com> Sender: news@bbn.com Reply-To: fkittred@spca.bbn.com (Fletcher Kittredge) Organization: Bolt Beranek and Newman Inc., Cambridge MA Lines: 22 In article <39989@cup.portal.com> LordBah@cup.portal.com (Jeffrey J Vanepps) writes: >I have a problem with telling when the other side of a socket connection >has exited. Normally a read/recv which returns zero after select(2) says >that there is data to be read signifies a closed connection. In my case, >the application can't use this technique. Here's the situation: So why don't you set SO_KEEPALIVE on the socket and respond to the SIGIO? If that is a problem for you, you could have R write to the producer's socket. If the send returns ENOCONN, then you take whatever action necessary. Throughput should not be a problem since the write won't block, and the producer can ignore the message. Note that doing your own polling is considered by many to be a more elegant solution than setting SO_KEEPALIVE. SO_KEEPALIVE causes additional network load. regards, fletcher Fletcher Kittredge Platforms and Tools Group, BBN Software Products 10 Fawcett Street, Cambridge, MA. 02138 617-873-3465 / fkittred@bbn.com / fkittred@das.harvard.edu