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

# lc\_socket\_close(3)

create and free Librecast sockets

Part of [lc\_socket\_new(3)](/lc_socket_new/3.md).

## NAME

lc\_socket\_new, lc\_socket\_close - create and free Librecast sockets

## LIBRARY

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

## SYNOPSIS

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

**lc\_socket\_t \*lc\_socket\_new(lc\_ctx\_t** *\*ctx***);** **void lc\_socket\_close(lc\_socket\_t** *\*sock***);**

Compile and link with *-llibrecast*.

## DESCRIPTION

**lc\_socket\_new**() creates a new Librecast socket. 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.

**lc\_socket\_free**() closes and frees a Librecast socket created with [**lc\_socket\_new**(3)](/lc_socket_new/3.md)

## RETURN VALUE

**lc\_socket\_new**() returns a pointer to a *lc\_socket\_t* handle. On error returns NULL and sets *errno.*

The **lc\_socket\_close**() function returns no value.

## ERRORS

**lc\_socket\_new**() 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\_socket\_new**() could also fail with any of the errors listed in [**socket**(2)](/socket/2.md) or [**setsockopt**(2)](/setsockopt/2.md).

## SEE ALSO

**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)
