Ø Termination
of Server Process
Ø Out-of-Band
Data Using SIG_URG
![]()
siganl ( sig, handler )
ü sig: SIGCHLD,
SIGKILL,
etc ...
(use % kill –l to list all
signals)
ü handler: SIG-IGN, SIG-DFL, etc., or specific-function
![]()
Example:
% cd
/home/cs779/stevens3rd.book/unpv13e/tcpcliserv
ü Run serever: tcpserv01.c
(it uses str_echo.c )
% tcpserv01
ü Run client: tcpcli01.c
(it uses str_cli.c )
% tcpcli01 127.0.0.1
ü Use ps -a to find the pid of the child process P
serving the client.
ü kill
the client process tcpcli01
ü Use ps -a and
you will find the pid of P is <defunct> i.e., child
process is zombie.
Fix:
In tcpserv02.c
add a line:
Signal (SIGCHLD, sig_chld) ;
ü This is a Bad Fix !
This
fix KILLS the
server! (since Accept
return EINTR error).
ü Good Fix:
Use
accept (instead of the wrapper
function Accept) in tcpserv03.c
to check for EINTR and continue.
Multiple
childern:
§ tcpcli04.c creates 50 connections to the tcpserv03.c
(it use: sigchldwait.c)
killing the client may cause zomies leftover.
§ To solve this use: tcpserv04.c
(it uses: sigchldwaitpid.c)
![]()
Example: connect_timeo.c
Example: timeoDaytimeClient.c
(uses)
tcpDaytimeServer.c
% cd /home/cs779/stevens3rd.book/unpv13e/nonblock/example
% tcpDaytimeServer 1234
0 25
% timeoDaytimeClient
127.0.0.1 1234 0 & (will get the time)
% timeoDaytimeClient
127.0.0.1 1234 10 &
(will timeout)
% timeoDaytimeClient
127.0.0.1 1234 50 & (will get the time)
![]()
Ø Termination of Server Process:
à readline error: Connection reset by peer.
Occures when you
read from a socket that has received FIN.
à writen error:
Broken pipe.
Occures when you write to a socket that has recieved RST.
§ Crashing Server Host: Client gets Timeout.
§ Crashing & Reboot Host: Client gets RST
§ Normal Shutdown of Host: Client gets FIN
![]()
Ø Out-of-Band
data Using
SIG_URG:
Each
out-of-band data sent generates SIGURG
at the receiver.
Example:
% cd
/home/cs779/stevens3rd.book/unpv13e/oob
ü Run serever: tcprecv01.c
%
tcprecv01 10234
ü Run client:
tcpsend01.c
%
tcpsend01 127.0.0.1 10234
Stopped Flow:
If TCP flow control causes the sender to stop
sending data:
TCP still allows out-of-band notification to be sent.
Example:
% cd
/home/cs779/stevens3rd.book/unpv13e/oob
ü Run serever: tcprecv05.c
%
tcprecv05 10234
ü Run client:
tcpsend05.c
%
tcpsend05 127.0.0.1 10234
![]()
To detect
the early failure of either the peer host or the communication path to the peer.

ü heartbeatcli.c &
ü tcpcli02.c it uses:
strcliselect02.c and it uses:
heartbeat_cli(sockfd, 1, 5);
ü tcpserv02.c it uses:
strecho02.c and
it uses:
heartbeat_serv(sockfd, 1, 5);
Run serever & client as follows:
%
tcpserv02 10111
%
tcpcli02 127.0.0.1 10111
Back Doors:
% tcpserv02
% tcpcli02
Type: CTRL_C for tcpcli02.