home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!usc!rpi!batcomputer!munnari.oz.au!metro!otc!balrog!camh
- From: camh@nms.otca.oz.au (Cameron Hutchison)
- Newsgroups: comp.unix.programmer
- Subject: Detecting a broken socket
- Keywords: socket, SunOS, keep_alive
- Message-ID: <camh.715839302@balrog>
- Date: 7 Sep 92 04:15:02 GMT
- Sender: news@otc.otca.oz
- Lines: 37
-
- I have a problem with a socket connection that I cant seem to find a
- solution for. I am trying to detect when the remote end of a socket dies.
- I am doing all this on Sun 4's running SunOS 4.1.2.
-
- 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. However, I cant seem to find any way
- of telling when the other end of the socket dies. Normally I would
- be able to tell because a write(2) would fail, but in this instance,
- I'm only reading from the socket.
-
- I have experimented with the keep alive timer option but I cant seem
- to get it to work. I set the option correctly with setsockopt(2) (and
- have verified that it is set by reading it back with getsockopt(2)).
- As I understand it, my select(2) call will return with a read ready
- on the broken socket and the read(2) will return 0 bytes. This just
- isn't happening. The select does not return.
-
- My method of testing the keep alive timer was to have a server
- machine "emulating" the comms server (from the standpoint of a socket
- connection) and a client machine to connect to it. I then simulated
- the dropping of the connection by pulling the network connection
- to the server machine. I let the client machine run for about 45
- minutes before giving up. The client machine did not detect the
- broken connection.
-
- Another solution might be to periodically check the socket. However,
- I don't know how to check the socket. I don't want to do any reads or
- writes (ie the check must be passive) and I could see no other system
- calls available that might help.
-
- Does anybody have any clues as to what is going on with the keep
- alive timer, or failing that, a way to periodically check the socket?
-
- --
- Cameron Hutchison (camh@nms.otca.oz.au)
- Beware of the clams
-