---
name: "lc_socketpair"
section: "3"
platform: "linux"
package: "liblibrecast-dev"
version: "0.9.1-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/lc_socketpair"
---

# lc\_socketpair(3)

create a pair of connected Librecast sockets

## NAME

lc\_socketpair - create a pair of connected Librecast sockets

## LIBRARY

Librecast library (*liblibrecast*, *-llibrecast*)

## SYNOPSIS

```
#include <librecast/net.h>
```

**int lc\_socketpair(lc\_ctx\_t** *\*ctx***, lc\_socket\_t** *\*sock***\[2\]);**

Compile and link with *-llibrecast*.

## DESCRIPTION

**lc\_socketpair**() creates a pair of connected Librecast sockets.

Call [**lc\_socket\_close**(3)](/lc_socket_close/3.md) when done.

Sockets can also be freed by a call to [**lc\_ctx\_free**(3)](/lc_ctx_free/3.md) on the Librecast context which will free the context and all associated sockets and channels.

## RETURN VALUE

On success, zero is returned. On error, -1 is returned, *errno* is set to indicate the  error.

## ERRORS

**lc\_socketpair**() can fail with the following errors:

- **ENOMEM**

  Out of memory. Possibly, the application hit the **RLIMIT\_AS** or **RLIMIT\_DATA** limit described in [**getrlimit**(2)](/getrlimit/2.md).

**lc\_socketpair**() can also fail with any of the errors described in [**socketpair**(2)](/socketpair/2.md).

## SEE ALSO

[**lc\_socket\_new**(3)](/lc_socket_new/3.md), **lc\_channel\_new**(3), [**lc\_ctx\_new**(3)](/lc_ctx_new/3.md), **lc\_socket\_setopt**(3), [**setsockopt**(2)](/setsockopt/2.md), [**socket**(2)](/socket/2.md), [**socketpair**(2)](/socketpair/2.md)
