#include <sys/types.h>
#include <sys/socket.h>
int shutdown(int socket_descriptor,
int how)
#define _XOPEN_SOURCE 520
#include <sys/socket.h>
int shutdown(int socket_descriptor,
int how)
The shutdown() function is used to disable reading, writing, or reading and writing on a socket.
There are two versions of the API, as shown above. The base i5/OS API uses BSD 4.3 structures and syntax. The other uses syntax and structures compatible with the UNIX 98 programming interface specifications. You can select the UNIX 98 compatible interface with the _XOPEN_SOURCE macro.
| SHUT_RD or 0 | No more data can be received. |
| SHUT_WR or 1 | No more data can be sent. |
| SHUT_RDWR or 2 | No more data can be sent or received. |
No authorization is required.
shutdown() returns an integer. Possible values are:
When shutdown() fails, errno can be set to one of the following:
| [EBADF] | Descriptor not valid. |
| [EINVAL] | Parameter not valid.
This error code indicates one of the following:
|
[ENOTCONN] |
The specified descriptor does not reference a
connected socket. ![]() |
| [ENOTSOCK] | The specified descriptor does not reference a
socket. |
| [EIO] | Input/output error. |
| [EUNATCH] | The protocol required to support the specified
address family is not available at this time.
Note: This errno is not returned if the how parameter is 0. |
| [EUNKNOWN] | Unknown system state. |
| Message ID | Error Message Text |
|---|---|
| CPE3418 E | Possible APAR condition or hardware failure. |
| CPF9872 E | Program or service program &1 in library &2 ended. Reason code &3. |
| CPFA081 E | Unable to set return value or error code. |
If the socket is being shared
across multiple processes, any blocking input operations are deblocked by this
action.
If the socket is being shared
across multiple processes or threads, any blocking output functions are deblocked
with a return value of -1 and an error code of [epipe].

| Top | UNIX-Type APIs | APIs by category |