ITEM: K1644L

Program is not picking up trap for SIGPIPE when connection breaks


AIX is 3.2.5. 
I've got a program that has a signal trap routine for SIGPIPE. The program opens
up a socket, with the setsockopt() I turn on SO_KEEPALIVE, the program proceeds 
to do successive non-blocking writes to the socket. We use the select() function 
to determine when writes are completing. We are trying to detect any break 
in communications. To simulate this I disconnect the LAN cable. When we 
do this our writes get buffered up and our SIGPIPE trap routine is not getting 
called. Can you please help us detect this break in communications. 


I was able to recreate the problem in the lab. The program continues writting 
even when the connection is broken. It buffers up the data and retransmits the 
data upon reconnection as long as this occurs within the tcp_keepidle time 
period and the buffer is not full.   

The detection of a disconnection in the physical layer is performed
at the adapter/device driver layer. Anyway the driver may not
be able to detect and pass on this information to the higher layers.

For example for Ethernet even if this information is detected, it is not
provided to the higher layers. The Network interface layer gets no
indication from the driver that the physical connection is broken. Hence
the upper layers IP and ARP get no indication. Hence no asynchronous
indication from the SOCKET layer can be provided to the applications. The
only mechanism that can be used to detect disconnetion at the physical
layer is, acknowledgement with timers at higher layers. Hence at the
application layer you can do the same.

Anyway I do not believe it is correct to perform network recovery at
the application layer especially if it is using TCP layer. The TCP layer
is designed to perform recovery from an unreliable link layer going up or down.

If you are interested in terminating a TCP connection as soon as
possible after a physical connection is broken then you may want to
look at the tcp_keepidle and tcp_keepintvl "no" options.  Here is a brief
description of how TCP behaves.

A TCP connection is terminated if there is no activity on the connection for a
certain period of time. The minimum period we wait before breaking
a connection is tcp_keepidle + tcp_keepintvl * TCPTV_KEEPCNT


In AIX 3.2 tcp_keepidle ( deflt 120 minutes ) and tcp_keepintvl
( deflt 75 seconds )  can be modified using "no" options.

The TCP will make TCPTV_KEEPCNT number of probes / attempts to
determine if the connection is broken. The first attempt
is made after tcp_keepidle time and then remaining attempts are made
after tcp_keepintvl times each.

If the peer TCP does not respond then a SIGPIPE signal is given to the

You can tune the above mentioned "no" options to suite your
need. You can also look at the file \

Support Line: Program is not picking up trap for SIGPIPE when connection breaks ITEM: K1644L
Dated: June 1994 Category: N/A
This HTML file was generated 99/06/24~13:30:42
Comments or suggestions? Contact us