Using Shutdown - HP Rp3440-4 - 9000 - 0 MB RAM Programmer's Manual

Bsd sockets interface programmer’s guide
Hide thumbs Also See for Rp3440-4 - 9000 - 0 MB RAM:
Table of Contents

Advertisement

Advanced Topics for Stream Sockets

Using Shutdown

Using Shutdown
When your program is done reading or writing on a particular socket
connection, you can use shutdown to bring down a part of the
connection.
When one process uses shutdown on a socket descriptor, all other
processes with the same socket descriptor are affected. shutdown causes
all or part of a full-duplex connection on the specified socket to be
disabled. When shutdown is executed, the specified socket is marked
unable to send or receive, according to the value of how.
• If how = 0, the specified socket can no longer receive data. The
connection is not completely down until both sides have done a
shutdown or a close.
• If how = 1, shutdown starts a graceful disconnect by attempting to
send any unsent data before preventing further sending. shutdown
sends an end-of-file condition to the peer, indicating that there are no
more data to be sent.
Once both shutdown(s, 0) and shutdown(s, 1) have been
executed on the same socket descriptor, the only valid operation on
the socket at this point is a close.
• If how = 2, the specified socket can no longer send or receive data. The
only valid operation on the socket is a close. This has the same effect
as executing shutdown(s, 0) and shutdown(s, 1) on the same
socket descriptor.
If you use close on a socket, close pays attention to the SO_LINGER
option, but shutdown(s, 2) does not. With close, the socket
descriptor is deallocated and the last process using the socket destroys it.
shutdown and its parameters are described in the following table.
Include files:
none
System call:
shutdown(s,how)
int s, how;
78
Chapter 3

Advertisement

Table of Contents
loading

Table of Contents