Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!samsung!uunet!brunix!m2jhc!jhc From: jhc@m2jhc.uucp (James H. Coombs) Newsgroups: comp.unix.questions Subject: Re: How can a server tell if a client is gone? Message-ID: <48479@brunix.UUCP> Date: 28 Aug 90 20:33:55 GMT References: <26DAAE36.74D6@wilbur.coyote.trw.com> Sender: news@brunix.UUCP Reply-To: jhc@m2jhc.UUCP () Organization: IRIS - Brown University Lines: 19 In article <26DAAE36.74D6@wilbur.coyote.trw.com> rudoff@mdi.com writes: >I am writing an application that uses a client-server model. I want the >server to be able to tell if the client has disappeared unexpectedly. > >I have been using RPC for interprocess communication on a Sun3 and Sun4 >running 4.0.3. I agree that your need is fundamental and that RPC should provide some direct support. In the meantime, you can consider the keepalive option on sockets. Also, if a socket read succeeds with 0 bytes read, you can reasonably infer that the other end has died. Others have better explanations and would probably recommend the use of a select(). Finally, if you attempt a write on a disconnected socket, the SIGPIPE signal will be raised. I don't know of any straightforward way to apply these techniques with RPC. --Jim