HP X.25/9000 Programmer's Guide
Chapter 3 43
Establishing and Terminating a Socket Connection
Terminating a Connection
NOTE Closing a socket immediately after sending data can result in data loss.
Shutting Down a Socket
When your program finishes reading or writing on a particular socket
connection, it can call shutdown(2) to bring down a part of the
connection. Unlike close(), shutdown() affects the entire socket and all
other socket descriptors. shutdown() causes all or part of an SVC to be
disabled regardless of how many other socket descriptors are open on the
socket.
Syntax for shutdown()
The following section describes the syntax for shutdown() and its
parameters:
int err;
int sd, how;
err = shutdown(sd, how);
sd A socket descriptor for a listen socket or an SVC socket. The call affects
the entire socket whether or not other socket descriptors are open on the
socket.
how Describes the type of shutdown. Can be set to one of three possible
values:
• 0 – disables data reception on the socket but the connection is not
cleared. If data is received on the connection, it is lost. The socket
descriptor can still be used to read any unread data and transmit
data.
• 1 – clears the connection. Unread data cannot be read using the
socket descriptor.
• 2 – disables reception and transmission. A CLEAR REQUEST packet
is sent on the SVC. Any unread data can be read.
On a listen socket all
how
values have the same effect—all requests in
the listen queue are cleared and any requests received after the
shutdown() are cleared.
36960-90061.bk Page 43 Friday, November 10, 2000 3:42 PM










