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

# lc\_share(3)

share and unshare files over multicast

## NAME

lc\_share, lc\_unshare - share and unshare files over multicast

## LIBRARY

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

## SYNOPSIS

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

**lc\_share\_t \*lc\_share(lc\_ctx\_t** *\*lctx***, mdex\_t** *\*mdex***, unsigned int** *ifx***,**                 **lc\_stat\_t** *\*stats***, lc\_sync\_options\_t** *\*opt***, int** *flags***);** **void lc\_unshare(lc\_share\_t** *\*share***);**

Compile and link with *-llibrecast*.

## DESCRIPTION

The **lc\_share** function shares the objects indexed in **mdex** on the interface given by **ifx**. If ifx is zero, the files are shared on all multicast-capable interfaces.

lc\_share starts MLD snooping (see IETF RFC 3810). When a join on a new IPv6 multicast group is detected, this is checked against the index provided by *mdex*. If a matching object is found, this is added to the sending queue, and the data for this object continues to be sent until MLD reports that there are no more listeners for this group.

The data sent is encoded using RaptorQ Forward Error Correction (see IETF RFC 6330), using the LCRQ library.

If *stats* is not NULL, transfer statistics will be returned in this structure.

*opt* is not used, at present, and must be NULL for compatibility with future versions.

The *flags* argument is the bitwise OR of zero of more of the following flags:

- **LC\_SHARE\_LOOPBACK**

  Set the loopback option *IPV6\_MULTICAST\_LOOP* on the sending socket.

## RETURN VALUE

**lc\_share**() returns a pointer to a *lc\_share\_t* handle, which should be freed by passing to **lc\_unshare**() when done. On error, NULL is returned, and *errno* is set to indicate the error.

The **lc\_unshare**() function returns no value, and preserves *errno*.

## ERRORS

- **ENOTSUP**

  **lc\_share**() is not supported with your current configuration. This error occurs when the librecast library is built without MLD support.

**ENOMEM** Not enough space/cannot allocate memory (POSIX.1-2001).

**EACCES** Permission to create a socket of the specified type and/or protocol is denied.

## NOTES

**lc\_share** uses MLD snooping from libmld to detect which multicast groups are active, which uses a raw socket. On Linux, creating a raw socket requires **CAP\_NET\_RAW**. See **Capabilities**(7). On \*BSD the creation of a raw socket is restricted to the superuser. An application can drop these privileges after calling **lc\_share**.

To restrict syncing to a particular network interface, call [**lc\_ctx\_ifx**(3)](/lc_ctx_ifx/3.md) to set the default interface for the Librecast context before calling the appropriate sync function.

## SEE ALSO

[**lc\_ctx\_new**(3)](/lc_ctx_new/3.md), [**lc\_ctx\_ifx**(3)](/lc_ctx_ifx/3.md), [**mdex\_init**(3)](/mdex_init/3.md), [**mdex\_get**(3)](/mdex_get/3.md), [**mdex\_put**(3)](/mdex_put/3.md), [**mdex\_del**(3)](/mdex_del/3.md), [**lcrq**(7)](/lcrq/7.md)
