Please enable JavaScript to view this site.

A-Shell Consolidated Reference

The TCPOP_CLOSE operation used to (in TCPCLI/TCPSRV) issue both a bi-directional shutdown and a close. In TCPX, it only closes the socket. The distinction between close and shutdown is as follows:

Shutdown sends a signal to the remote end indicating that the sender is shutting down its end of the socket. Since sockets are full duplex, it is possible to shutdown just the sending side, or the receiving side or both. Two new flags, TCPXFLG_SHUTRD and TCPXFLG_SHUTWR have been added to allow the application to take advantage of this capability. If both, or neither, are specified, the socket is shut down in both directions. Shutdown does not substitute for close though, and therefore should be followed (eventually) by a normal close.
Close will generally have the same effect as a shutdown in both directions, except in the case where a socket is being shared by a parent and child process. The parent may have accepted the connection, then used XCALL SUBMIT to fork a child, which inherits the connection. Normally the parent would then close its connection socket. In the case, the close will not have any effect on the other end, since the child still has the socket open. Shutdown, on the other hand, would cause the other end to get an error if tried to read or write to the socket. When the child closes the socket, since it is the last one at its end to have it open, it will really be closed.

If the remote side attempts to read from the socket (or is in a blocking read) when the local socket is closed, it will return an error, although the precise error number may vary between operating systems and how the remote side performed the close/shutdown.