LC_RECV(3)

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

πŸ’– LC_RECV(3) πŸ’–

ok so bestie, we're in the Librecast Programmer's Manual rn and this page is literally all about receiving data over multicast. the manual name is LC_RECV and it's section 3, iykyk. sit down, hydrate, let's go 🫢


✨ NAME ✨

lc_recvtree, lc_recvchunk, lc_recvdir β€” receive data over multicast

πŸ“š LIBRARY πŸ“š

Librecast library (liblibrecast, -llibrecast)


🌸 SYNOPSIS 🌸

#include <librecast/sync.h>

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

Compile and link with -llibrecast. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

ok so every single one of these functions does the same iconic thing at its core: it receives data over multicast by joining the librecast channel that gets formed from the hash you hand it. that's the vibe. that's the whole assignment. ✨

lc_recvtree β€” this one receives the merkle tree structure from channel hash and puts it into tree. tree girlies, this is your moment 🌳

lc_recvchunk β€” this one receives a chunk of data of length len from channel hash, and writes it into the memory pointed to by data. and bestie, len can be fragmented over several packets β€” she's flexible like that, no stress πŸ’–

lc_recvdir β€” this one is a wrapper for lc_recvtree(3) and it's a little picky, ngl. if the object it received is not a directory, it returns -1 and sets errno to ENOTDIR. she said directory only, respectfully πŸš«πŸ“

now for the little details that matter:

  • if stats is not NULL, the transfer statistics will be returned in that structure. so if you want the receipts, pass it in 🧾
  • opt is not used, at present, and it must be NULL for compatibility with future versions. don't be cute, just pass NULL 🫠
  • flags is not used, at present, and it must be zero for compatibility with future versions. zero. that's it. that's the number πŸ”₯
fr fr: opt must be NULL and flags must be zero. this is for compatibility with future versions, so don't try to be clever and sneak something else in there, it's giving undefined chaos energy 😭

⭐ RETURN VALUE ⭐

these calls return the number of bytes received, or -1 if an error occurred. and if there's an error? errno gets set to tell you what went wrong. she always leaves a note πŸ’Œ


πŸ’€ ERRORS πŸ’€

  • EINVAL β€” Invalid argument. you gave her something she can't work with πŸ™ˆ
  • ENOMEM β€” Not enough space/cannot allocate memory (POSIX.1-2001). the memory said no πŸ’”
  • ENOTDIR β€” Not a directory. lc_recvdir said what she said πŸ“‚βŒ

πŸ‘‘ SEE ALSO πŸ‘‘

lc_ctx_new(3), lc_share(3), lc_sendtree(3), lc_sendchunk(3)


ok that's the whole page bestie, you ate that πŸ“βœ¨ this was the Librecast manual, dated 2025-06-09, and you just finished reading LC_RECV(3). go forth and receive, main character πŸ’…πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from