table of contents
LC_SYNC(3) | Librecast Programmer's Manual | LC_SYNC(3) |
NAME¶
lc_sync, lc_syncfile - synchronize memory or files over multicast
LIBRARY¶
Librecast library (liblibrecast, -llibrecast)
SYNOPSIS¶
#include <librecast/sync.h>
ssize_t lc_sync(lc_ctx_t *lctx, unsigned char *hash, void *data, const size_t len, q_t *q, lc_stat_t *stats, lc_sync_options_t *opt, int flags); ssize_t lc_syncfile(lc_ctx_t *lctx, unsigned char *hash, const char *pathname, q_t *q, lc_stat_t *stats, lc_sync_options_t *opt, int flags);
Compile and link with -llibrecast.
DESCRIPTION¶
The lc_sync() function synchronizes the memory area pointed to by data of length len with data fetched from the network.
The lc_syncfile() synchronizes the file at pathname with with data fetched from the network. The file will be created if it does not exist.
hash is used to create the multicast address from which to fetch the merkle tree of the source data. This tree is compared to the merkle tree of the memory at data to find which chunks differ, and these chunks are fetched from the network using their hashes to create the multicast source addresses.
lctx is a Librecast context, created with lc_ctx_new(3).
If q is not NULL, it must point to a queue q_t structure previously initialized with q_init(3). This queue will have jobs enqueued to build the tree. This is normally used in conjunction with a threadpool created with q_pool_create(3) with threads all calling q_job_seek(3).
If q is NULL, the creation and destruction of a queue and threadpool will be handled automatically.
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.
flags is not used, at present, and must be zero for compatibility with future versions.
RETURN VALUE¶
These calls return the number of bytes received, or -1 if an error occurred. On error, NULL is returned, and errno is set to indicate the error.
ERRORS¶
- EINVAL
- Invalid argument.
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.
lc_syncfile() can also fail with any of the errors for lc_mmapfile(3).
NOTES¶
To restrict syncing to a particular network interface, call lc_ctx_ifx(3) to set the default interface for the Librecast context before calling the appropriate sync function.
SEE ALSO¶
lc_ctx_new(3), lc_ctx_ifx(3), lc_mmapfile(3), lc_share(3), mdex_init(3), mdex_free(3), mdex_add(3), mdex_addfile(3), mdex_alias(3), mdex_get(3), mdex_put(3), mdex_del(3), lcrq(7)
2023-08-02 | LIBRECAST |