---
name: "shutdown"
section: "2"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["linux", "freebsd", "macos"]
url: "https://new.carta.tech/shutdown/2"
---

# shutdown(2)

disable sends and/or receives on a socket

## NAME

**shutdown** – disable sends and/or receives on a socket

## LIBRARY

Standard C Library (libc, -lc)

## SYNOPSIS

**#include \<sys/types.h\>**

**#include \<sys/socket.h\>**

*int*\

**shutdown**(*int s*, *int how*);

## DESCRIPTION

The **shutdown**() system call disables sends or receives on a socket. The *how* argument specifies the type of shutdown. Possible values are:

- SHUT\_RD

  Further receives will be disallowed.

- SHUT\_WR

  Further sends will be disallowed. This may cause actions specific to the protocol family of the socket *s* to happen; see IMPLEMENTATION NOTES.

- SHUT\_RDWR

  Further sends and receives will be disallowed. Implies SHUT\_WR.

If the file descriptor *s* is associated with a SOCK\_STREAM socket, all or part of the full-duplex connection will be shut down.

## IMPLEMENTATION NOTES

The following protocol specific actions apply to the use of SHUT\_WR (and potentially also SHUT\_RDWR), based on the properties of the socket associated with the file descriptor *s*.

| | | | |
| --- | --- | --- | --- |
| **Domain** | **Type** | **Protocol** | **Action** |
| PF\_INET | SOCK\_DGRAM | IPPROTO\_SCTP |  |
| PF\_INET | SOCK\_DGRAM | IPPROTO\_UDP |  |
| PF\_INET | SOCK\_STREAM | IPPROTO\_SCTP |  |
| PF\_INET | SOCK\_STREAM | IPPROTO\_TCP |  |
| PF\_INET6 | SOCK\_DGRAM | IPPROTO\_SCTP |  |
| PF\_INET6 | SOCK\_DGRAM | IPPROTO\_UDP |  |
| PF\_INET6 | SOCK\_STREAM | IPPROTO\_SCTP |  |
| PF\_INET6 | SOCK\_STREAM | IPPROTO\_TCP |  |

## RETURN VALUES

The **shutdown()** function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate the error.

## ERRORS

The **shutdown**() system call fails if:

- \[EBADF\]

  The *s* argument is not a valid file descriptor.

- \[EINVAL\]

  The *how* argument is invalid.

- \[ENOTCONN\]

  The *s* argument specifies a socket which is not connected.

- \[ENOTSOCK\]

  The *s* argument does not refer to a socket.

## SEE ALSO

[connect(2)](/connect/2.md), [socket(2)](/socket/2.md), [inet(4)](/inet/4.md), [inet6(4)](/inet6/4.md)

## STANDARDS

The **shutdown**() system call is expected to comply with IEEE Std 1003.1g-2000 (“POSIX.1g”), when finalized.

## HISTORY

The **shutdown**() system call appeared in 4.2BSD. The SHUT\_RD, SHUT\_WR, and SHUT\_RDWR constants appeared in IEEE Std 1003.1g-2000 (“POSIX.1g”).

## AUTHORS

This manual page was updated by Bruce M. Simpson ⟨*bms@FreeBSD.org*⟩ to reflect how **shutdown**() behaves with PF\_INET and PF\_INET6 sockets.

## BUGS

The ICMP “port unreachable” message should be generated in response to datagrams received on a local port to which *s* is bound after **shutdown**() is called.
