Ø 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
128.82.4.103
à Use ps -a to find the pid of the child process X serving the
client.
à Kill
the client process
à Use ps -a and you will find the pid of X is <defunct>
i.e., child process is zombie.
Fix:
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 use: 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 1234
à
Run client: tcpsend01.c
%
tcpsend01 128.82.4.210 1234
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 1234
à
Run client: tcpsend05.c
%
tcpsend05 128.82.4.210 1234
![]()
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 128.82.4.210 10111