Path: utzoo!attcan!uunet!motcid!damenf From: damenf@motcid.UUCP (Frederick Damen) Newsgroups: comp.unix.questions Subject: Re: reading on sockets when connection breaks Message-ID: <5727@navy40.UUCP> Date: 11 Dec 90 17:50:11 GMT References: <25205@adm.brl.mil> <1990Dec6.055353.23846@Think.COM> Organization: Motorola Inc. - Cellular Infrastructure Div., Arlington Heights, IL 60004 Lines: 53 In article <1990Dec6.055353.23846@Think.COM> barmar@think.com (Barry Margolin) writes: >If you're willing to assume that incommunicado means dead you can use a >keepalive, an empty packet that is sent periodically in order to elicit an >acknowledgement. If you're using Unix sockets, the SO_KEEPALIVE option can >be enabled to automate this. After RTFMs, I have a few questions and assumptions that need confirming: 1) After reading some related information on SIGPIPE and running a test program it seems as though SIGPIPE is only raised on a pipe/socket that has been written to. In most/all the documentation on SIGPIPE that I have seen it always refers to writing to the pipe/socket. In test program that I have written the read(2) command will return a 0 if there has not been any writes to that end of the socket, the read(2) command will cause a SIGPIPE if that end of the socket has been previously written to. This happens with or without SO_KEEPALIVE set. Q: Is SIGPIPE only raised for the end of the socket/pipe that has been written to? 2) SunOS 4.0.1 man page for setsockopt(2) Says: SO_KEEPALIVE enables the periodic transmission of messages on a connected socket. Should the connected party fail to respond to these messages, the con- nection is considered broken and processes using the socket are notified using a SIGPIPE signal. Q: What is the period of these messages? Q: When is the SIGPIPE sent: After n(n=1) messages are not responded to? When the next I/O operation is performed on this socket after a nonresponce? Q: Define processess *using* the socket. Is this: Processes that have written to the socket? Processes that have an open file descriptor for this socket? Processes at both ends of socket connection? Processes that are currently performing and I/O operation on the socket? 3) After the signal handler for SIGPIPE is called how do/should you tell which socket caused the SIGPIPE? I am on a Sun 3/80 running SunOS 4.0.1. I am using AF_INET, SOCK_STREAM. I have RTFM and then some. I have written some programs usings sockets and understand(?) the basics. Thanks in advance for any answers or rtfm(references to f___ manuals) that might be more enlighting. Fred -- Fred Damen 1501 W. Shure Drive Motorola, Inc. Arlington Heights, IL 60004 Cellular Infrastructure Division 708 632-4641 ...!uunet!motcid!damenf