---
name: "explain_socketpair_or_die"
section: "3"
platform: "linux"
package: "libexplain-dev"
version: "1.4.D001-16"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/explain_socketpair_or_die"
---

# explain\_socketpair\_or\_die(3)

create pair of connected sockets and report errors

## NAME

explain\_socketpair\_or\_die - create pair of connected sockets and report errors

## SYNOPSIS

\#include \<libexplain/socketpair.h\>

void explain\_socketpair\_or\_die(int domain, int type, int protocol, int \*sv);\
 int explain\_socketpair\_on\_error(int domain, int type, int protocol, int \*sv);

## DESCRIPTION

The **explain\_socketpair\_or\_die** function is used to call the [*socketpair*(2)](/socketpair/2.md) system call. On failure an explanation will be printed to *stderr*, obtained from the [*explain\_socketpair*(3)](/explain_socketpair/3.md) function, and then the process terminates by calling `exit(EXIT_FAILURE)`.

The **explain\_socketpair\_on\_error** function is used to call the [*socketpair*(2)](/socketpair/2.md) system call. On failure an explanation will be printed to *stderr*, obtained from the [*explain\_socketpair*(3)](/explain_socketpair/3.md) function, but still returns to the caller.

- *domain*

  The domain, exactly as to be passed to the [*socketpair*(2)](/socketpair/2.md) system call.

- *type*

  The type, exactly as to be passed to the [*socketpair*(2)](/socketpair/2.md) system call.

- *protocol*

  The protocol, exactly as to be passed to the [*socketpair*(2)](/socketpair/2.md) system call.

- *sv*

  The sv, exactly as to be passed to the [*socketpair*(2)](/socketpair/2.md) system call.

## RETURN VALUE

The **explain\_socketpair\_or\_die** function only returns on success, see [*socketpair*(2)](/socketpair/2.md) for more information. On failure, prints an explanation and exits, it does not return.

The **explain\_socketpair\_on\_error** function always returns the value return by the wrapped [*socketpair*(2)](/socketpair/2.md) system call.

## EXAMPLE

The **explain\_socketpair\_or\_die** function is intended to be used in a fashion similar to the following example:

```
explain_socketpair_or_die(domain, type, protocol, sv);
```

## SEE ALSO

- [*socketpair*(2)](/socketpair/2.md)

  create a pair of connected sockets

- [*explain\_socketpair*(3)](/explain_socketpair/3.md)

  explain [*socketpair*(2)](/socketpair/2.md) errors

- [*exit*(2)](/exit/2.md)

  terminate the calling process

## COPYRIGHT

libexplain version 1.4\
 Copyright (C) 2010 Peter Miller
