home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.programmer
- Path: sparky!uunet!munnari.oz.au!spool.mu.edu!sol.ctr.columbia.edu!destroyer!ncar!noao!rstevens
- From: rstevens@noao.edu (W. Richard Stevens)
- Subject: Re: Detecting a broken socket
- Message-ID: <1992Sep7.220601.7136@noao.edu>
- Keywords: socket, SunOS, keep_alive
- Sender: news@noao.edu
- Nntp-Posting-Host: gemini.tuc.noao.edu
- Organization: National Optical Astronomy Observatories, Tucson, AZ, USA
- References: <camh.715839302@balrog>
- Date: Mon, 7 Sep 1992 22:06:01 GMT
- Lines: 17
-
- >The situation is that I have an open socket to a comms server that
- >occasionally dies. When this happens I would like to close down the
- >connection and open a new one.
-
- What do you mean by "dies"? If the process dies but the host stays up
- (and I'm assuming you're using TCP), then the connection is closed and
- your end should appear readable with the read returning 0, which you
- indicate you've tried. If the comms server is a dedicated box that
- crashes, and perhaps reboots, then maybe it's not closing the connection,
- which accounts for why your select didn't indicate readable. If the comms
- server isn't sending out a FIN segment, your end won't detect that it's
- crashed. If the comms server does reboot then the keepalive would work,
- but as someone else has indicated, the timer value is usually not
- per-process-configurable, and the recommended default is now 2 hours
- of inactivity on the connection before a keepalive packet is sent.
-
- Rich Stevens (rstevens@noao.edu)
-