SHUTDOWN
One way to terminate a network connection is to issue the CLOSE call which attempts to complete all outstanding data transmission requests before breaking the connection. The SHUTDOWN call can be used to close one-way traffic while completing data transfer in the other direction. The HOW parameter determines the direction of traffic to shutdown.
If you issue SHUTDOWN for a socket that currently has
outstanding socket calls pending, see Table 1 to
determine the effects of this operation on the outstanding socket
calls.
| Shutdown | ||||
|---|---|---|---|---|
| Socket calls in local program | Local Program | Remote Program | ||
| Shutdown END_TO | Shutdown END_FROM | Shutdown END_FROM | Shutdown END_TO | |
| Write calls | Error number EPIPE on first call | Error number EPIPE on second call* | ||
| Read calls | Zero length return code | Zero length return code | ||
| * If you issue two write calls immediately, both might be successful, and an EPIPE error number might not be returned until a third write call is issued. | ||||
Example of SHUTDOWN call
SOC_FUNCTION DC CL16'SHUTDOWN'
S DS H
HOW DS F
END_FROM EQU 0
END_TO EQU 1
END_BOTH EQU 2
ERRNO DS F
RETCODE DS F
CALL DFHSOKET,(SOC_FUNCTION,S,HOW,ERRNO,RETCODE)
Input parameters
- SOC_FUNCTION
- A 16-byte character field containing SHUTDOWN. The field is left-justified and padded on the right with blanks.
- S
- A halfword binary number set to the socket descriptor of the socket to be shutdown.
- HOW
- A fullword binary field. Set to specify whether all or part of
a connection is to be shut down. The following values can be set:
- Value
- Description
- 0 (END_FROM)
- Ends further receive operations.
- 1 (END_TO)
- Ends further send operations.
- 2 (END_BOTH)
- Ends further send and receive operations.
Output parameters
- ERRNO
- A fullword binary field. If RETCODE is negative, the field contains an error number. See Return codes for information about ERRNO return codes.
- RETCODE
- A fullword binary field that returns one of the following:
- Value
- Description
- 0
- Successful call
- -1
- Check ERRNO for an error code