---
name: "io_socketpair"
section: "3diet"
platform: "linux"
package: "libowfat-dev"
version: "0.28-2"
release: "Debian 6.0 (Squeeze)"
platforms: ["linux"]
url: "https://new.carta.tech/io_socketpair/3diet"
---

# io\_socketpair(3diet)

create a pair of sockets

## NAME

io\_socketpair - create a pair of sockets

## SYNTAX

**#include \<io.h\>**

int **io\_socketpair**(int64 pfd\[2\]);

## DESCRIPTION

io\_socketpair creates a new UNIX socket pair and writes both descriptors to *d*.  The socket pair works much like a pipe, but it is bidirectional (i.e. both descriptors are for reading and writing).

io\_socketpair returns 1 to indicate success. If something goes wrong, io\_socketpair returns 0, setting errno to indicate the error; in this case it frees any memory that it allocated for the new socketpair, and it leaves *d* alone.

## SEE ALSO

[io\_readfile(3)](/io_readfile/3.md), [io\_createfile(3)](/io_createfile/3.md), [io\_pipe(3)](/io_pipe/3.md)
