LC_SEND(3)

πŸ“¦
version 0.11.2 Β· 2 versions
, in nixos 26.05, nixpkgs unstable, ubuntu resolute, ubuntu stonking

πŸ’– LC_SEND β€” send data over multicast πŸ’–

okay bestie, so this is a page from the Librecast Programmer's Manual, section 3 (LC_SEND(3)). yes it's giving "networking homework" but honestly? it ate. let's get into it πŸ¦‹


🌸 NAME 🌸

lc_sendtree, lc_sendchunk β€” send data over multicast. that's the whole vibe. no cap.


✨ LIBRARY ✨

Librecast library (liblibrecast, -llibrecast). that's your girl, that's the whole squad πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

okay so first things first, you gotta invite her in:

#include <librecast/sync.h>

and then these three icons walk in:

ssize_t lc_sendtree(lc_ctx_t *lctx, unsigned char *hash, const mtree_t *tree,
        lc_stat_t *stats, lc_sync_options_t *opt, int flags);
ssize_t lc_sendchunk(lc_ctx_t *lctx, unsigned char *hash, const void *data,
        const size_t len, lc_stat_t *stats, lc_sync_options_t *opt, int flags);
ssize_t lc_senddir(lc_ctx_t *lctx, unsigned char *hash, net_tree_t *dir,
        lc_stat_t *stats, lc_sync_options_t *opt, int flags);

and when you build, you link her up like:

Compile and link with -llibrecast.

periodt. πŸ’–


🌈 DESCRIPTION 🌈

every single one of these functions does the same main-character move: it sends data over multicast on the librecast channel that gets formed from the hash you handed it. like, the hash is the address, iykyk.

LCRQ (RaptorQ) encoding is used when sending. and for trees where the receiver has no idea how long the thing is? πŸ‘€ those include an OTI header (RaptorQ FEC Object Transmission Information header β€” see RFC 6330) with each packet. so the receiver isn't just guessing, bestie, she's informed. πŸ’…

sending continues in a loop until the calling thread is cancelled. she will keep going. she does not stop. she is loyal like that 😭

the lc_sendtree function sends the merkle tree structure tree on channel hash. the lc_sendchunk function sends len bytes of data. both iconic, both necessary, no notes.

the lc_senddir function is a wrapper for lc_sendtree(3) which sends a directory object and adjusts the sending size to account for the directory data. she's the little sister who does the extra math so you don't have to 🫢

if stats is not NULL, transfer statistics will be returned in this structure. receipts! we love receipts. ✨

opt is not used, at present, and must be NULL for compatibility with future versions. so like… don't touch it. it's not ready yet. respect the boundary πŸ™ˆ


πŸ‘‘ the flags argument πŸ‘‘

flags is the bitwise OR of zero of more of the following flags. yes, zero is allowed, she's flexible:

  • LC_SHARE_LOOPBACK β€” Set the loopback option IPV6_MULTICAST_LOOP on the sending socket. basically: let her hear herself. 🎧

πŸ”₯ RETURN VALUE πŸ”₯

these calls return the number of bytes received, or -1 if an error occurred. and if an error did occur? errno is set to indicate the error. so check your errno, bestie, she's trying to tell you something πŸ’€


πŸ’œ ERRORS πŸ’œ

  • EINVAL β€” Invalid argument. you gave her something she cannot work with. respectfully.
  • ENOMEM β€” Not enough space/cannot allocate memory (POSIX.1-2001). the memory said no. it's not you, it's the RAM. 😭

πŸ¦‹ SEE ALSO πŸ¦‹

lc_ctx_new(3), lc_share(3), lc_sendtree(3), lc_sendchunk(3) β€” go read those next, they're literally the rest of the lore πŸ“


and that's the whole page, bestie!! mwah πŸ’‹ this one's from the Librecast crew, dated 2025-06-09, published under the LIBRECAST banner for manual page LC_SEND(3). go forth and multicast responsibly. slay. βœ¨πŸ’–πŸŽ€

πŸ“¦ where this page comes from