---
name: "disconnectx"
section: "2"
platform: "macos"
package: "xnu"
version: "12377.121.6"
release: "macOS 26.5"
platforms: ["macos"]
url: "https://new.carta.tech/disconnectx"
---

# disconnectx(2)

disconnects a connection on a socket

## NAME

**disconnectx** – disconnects a connection on a socket

## SYNOPSIS

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

*int*\

**disconnectx**(*int socket*, *sae\_associd\_t associd*, *sae\_connid\_t connid*);

## DESCRIPTION

The parameter *socket* is a socket.  The communication domain of the socket determines the availability and behavior of **disconnectx**(). For connection-oriented socket, **disconnectx**() is analogous to [shutdown(2)](/shutdown/2.md) with SHUT\_RDWR issued on the socket. For connectionless socket, it disassociates any existing association to the peer socket.

The parameter *associd* specifies the association identifier.  It should be set to SAE\_ASSOCID\_ANY.

The parameter *connid* should be set to SAE\_CONNID\_ANY.

## NOTES

**disconnectx**() is currently supported only on AF\_INET and AF\_INET6 sockets of type SOCK\_DGRAM and SOCK\_STREAM.

## RETURN VALUES

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

## ERRORS

The **disconnectx**() system call succeeds unless:

- \[EALREADY\]

  Operation already in progress.

- \[EBADF\]

  *Socket* is not a valid descriptor.

- \[EINVAL\]

  The *associd* or *connid* argument is invalid or the underlying protocol is no longer attached to *socket*.

- \[ENOTCONN\]

  The *socket* is not connected.

- \[ENOTSOCK\]

  *Socket* is a file, not a socket.

## SEE ALSO

[connect(2)](/connect/2.md), [connectx(2)](/connectx/2.md), [socket(2)](/socket/2.md), [compat(5)](/compat/5.md)

## HISTORY

The **disconnectx**() function call appeared in Darwin 15.0.0
