TCP/IP Programming Manual
Usage Guidelines
• Use shutdown on a socket created for waited operations, or shutdown_nw on a socket
created for nowait operations. The operation initiated by shutdown_nw must be completed
with a call to the AWAITIOX procedure.
• Because the shutdown function shuts down an active connection, it has no meaning for the
UDP or IP protocols.
• After a socket is shut down, there is a delay before the port can be reused. This delay occurs
so that any stray packets can be flushed from the network. The length of the delay varies,
based on the average round-trip time for packets in the network.
• The shutdown and shutdown_nw functions do not destroy the socket. To destroy a socket,
call the FILE_CLOSE procedure to destroy it.
See Nowait Call Errors (page 86) for information on error checking.
Example
The following example calls the shutdown function. (Data transfer on socket s1 is shutdown; no
further reads or writes are allowed.):
#include <socket.h>
#include <netdb.h>
...
\* Code to create socket s1, connect socket to server,
* and transfer data appears here.
*\
...
\* When finished transferring data, execute the following
* code.
*\
if (shutdown (s1, 2) < 0)
perror ("Shutdown failed.");
sock_close_reuse_nw
The sock_close_reuse_nw function is for use by servers that accept using the functions
accept_nw and accept_nw2. It replaces the close() function for an existing socket, marks
the socket for reuse and eliminates the need for a new socket to be created for the accept_nw2()
function call. The intention of this function is to improve performance by eliminating socket close
and open processing.
The sock_close_reuse_nw function is intended only for non fault-tolerant sockets
(SOCK_STREAM_NONFT). If the sock_close_reuse_nw function is used on a fault-tolerant socket
(SOCK_STREAM), the socket is closed and error EINVAL is returned to the application.
C Synopsis
#include <netdb.h>
error = sock_close_reuse_nw(socket, tag);
int error, socket;
long tag;
TAL Synopsis
?NOLIST, SOURCE SOCKDEFT
?NOLIST, SOURCE SOCKPROC
error := sock_close_reuse_nw(socket, tag);
INT(32) error,socket;
INT(32) tag;
190 Library Routines