TAKTUK(3)
π TAKTUK(3) β the TakTuk Library Functions Manual, bestie edition π
okay so. this is the manual for the TakTuk library functions, aka the C interface to the taktuk(1) communication facilities. it's giving "let me talk to my siblings in the parallel tree" energy and honestly? iconic. π«Ά
β¨ SYNOPSIS β¨
#include <taktuk.h>
const char *taktuk_error_msg(int msg_code);
int taktuk_init_threads();
int taktuk_leave_threads();
int taktuk_get(const char *field, unsigned long *result);
int taktuk_multi_send(const char *dest, const char *target,
const void *buffer, size_t length);
int taktuk_multi_sendv(const char *dest, const char *target,
const struct iovec *iov, int iovcnt);
int taktuk_send(unsigned long dest, unsigned long target,
const void *buffer, size_t length);
int taktuk_sendv(unsigned long dest, unsigned long target,
const struct iovec *iov, int iovcnt);
int taktuk_recv(unsigned long *from, void *buffer, size_t *length,
struct timeval *timeout);
int taktuk_recvv(unsigned long *from, const struct iovec *iov,
int iovcnt, struct timeval *timeout);
int taktuk_wait_message(unsigned long *from, size_t *size,
struct timeval *timeout);
int taktuk_read( void *buffer, size_t length );
int taktuk_readv( const struct iovec *iov, int iovcnt );
π DESCRIPTION π
The TakTuk communication layer interface library is literally your way to let programs that are running under the taktuk(1) command swap data with each other. the model is simple: sends that are multicast-like, and receives that can optionally time out. and no cap, it's built as a control facility β so please, do not treat this as a high performance communication library. it's a group chat, not a fiber optic cable. π
any program that uses the TakTuk C communication interface has to link itself against the taktuk and pthread libraries (the taktuk library ships with the distribution, don't worry). the headers for the communication functions plus the constant definitions live in taktuk.h, which is also provided with the distribution. π
the communication functions are:
π§ miscellaneous functions
int taktuk_init_threads();int taktuk_leave_threads();
these are the functions you call exactly once in the process β respectively before threads creation and after threads destruction β if you want the TakTuk C interface to be thread-safe.
but bestie, heads up: because of the way TakTuk is implemented, the handling ofrecvfunctions across several threads is completely sequentialized. this matters so much for timeouts. if a timeout is handed to arecvfunction, it will only be started at the calling thread's turn. in other words, issuing multiple timeoutedrecvcalls in several threads of the same process might result in timeouts longer than expected β they become at most the sum of all pendingrecvtimeouts. yeah. math. π
int taktuk_get(const char *field, unsigned long *result);
grabs some info from TakTuk and drops it into result. right now the available pieces of information are "target", "rank", "count", "father", "child_min" and "child_max". and this is a better way to get these than environment variables, because it takes into account the renumbering that might occur after a process spawn. so like, use this, fr fr. β¨
π£ multicast send functions
int taktuk_multi_send(const char *dest, const char *target, const void *buffer, size_t length);int taktuk_multi_sendv(const char *dest, const char *target, const struct iovec *iov, int iovcnt);
taktuk_multi_send sends the content of buffer, made of length bytes, to the set of target processes target present on the set of destinations dest. both dest and target are nul terminated character strings β go peek at taktuk(1) for the tea on set specifications for destination hosts and target processes. taktuk_multi_sendv is the vector variant of taktuk_multi_send (similar to the writev system function). π¦
π single host send/recv functions
int taktuk_send(unsigned long dest, unsigned long target, const void *buffer, size_t length);int taktuk_sendv(unsigned long dest, unsigned long target, const struct iovec *iov, int iovcnt);
sends the content of buffer, made of length bytes, to process target on the host dest (check taktuk(1) for more about target processes). in this case the target value might also be:
TAKTUK_TARGET_ANYβ targets the first process performing arecvTAKTUK_TARGET_ALLβ targets all the processesTAKTUK_TARGET_OUTPUTβ targets themessagestream rather than a process
taktuk_sendv is the vector variant of taktuk_send (similar to the writev system function). πΈ
int taktuk_recv(unsigned long *from, void *buffer, size_t *length, struct timeval *timeout);int taktuk_recvv(unsigned long *from, const struct iovec *iov, int iovcnt, struct timeval *timeout);
blocks until a message is received. if a regular message comes in, taktuk_recv sets the values of its arguments: from to the logical number of the sender, and buffer to the data received, which is made of length bytes. if timeout is not NULL, taktuk_recv() might receive a timeout notification. when that happens, taktuk_recv() returns the TAKTUK_ETMOUT error code. taktuk_recvv is the vector variant of taktuk_recv (similar to the readv system function). π
β οΈ WARNING: the buffer size should be sufficient to receive all the data of the matching send. if it's not, the program is likely to end up abruptly with a segmentation fault. that's not a vibe, that's a crash. π
π low-level recv functions
int taktuk_wait_message(unsigned long* from, size_t *size, struct timeval *timeout);int taktuk_read (void* buffer, size_t length);int taktuk_readv(const struct iovec *iov, int iovcnt);
taktuk_wait_message waits for a taktuk message to become available and sets from to the logical number of the sender and size to the size of the received message. it must be followed by a call to either taktuk_read or taktuk_readv to actually read the data (using the size that taktuk_wait_message gave you). and just like the other TakTuk receive functions, this one might return the TAKTUK_ETMOUT error code if timeout is not NULL and expires before the reception. β
if you don't know in advance the size of the data being sent to you, these lower level functions are your besties. fun fact: taktuk_recv is actually equivalent to a call to taktuk_wait_message, followed by error checks on buffer size, followed by a call to taktuk_read. same deal for taktuk_recvv. the way that recursion is just recursion, iykyk. π₯
π RETURN VALUE π
when an error occurs, all of these functions return one of the following numeric error codes. a textual description of the error is provided by the function taktuk_error_msg(), which takes the error code as an argument. cute, right?
error codes are the following:
TAKTUK_ESWRITβ a call towrite(2)failed. the code should be accessible usingerrno.TAKTUK_EFCLSDβ the communication channel to the TakTuk engine has been closed. this typically occurs when shutting down the logical network (using Ctrl-C on the root node for instance). rip the connection. πTAKTUK_ESREAD(receives only) β a call toread(2)failed. the code should be accessible usingerrno.TAKTUK_ETMOUT(receives only) β the call totaktuk_recv()(or its vectorized equivalent) or totaktuk_wait_messagetimeouted. this only occurs when giving a non nultimeoutvalue to these functions. β°TAKTUK_EALLOCβ an internal memory allocation failure occurred.TAKTUK_EIBUFFβ a buffer of incorrect size has been given to store all the data read by a receive function.TAKTUK_ENOCONβ the connector communication channels have not been found. this typically occurs when launching a TakTuk program without using TakTuk. not me launching the program without the thing the program needs πTAKTUK_EINVAL(get only) β the field given totaktuk_getis not a valid TakTuk field.TAKTUK_EMTXNM(init threads only) β no memory to allocate a new mutex.TAKTUK_EMTXAG(init threads only) β resources temporarily unavailable for new mutex allocation.
other error codes are internal TakTuk errors which should strongly suggest a bug in TakTuk. they also have a textual description that is returned by taktuk_error_msg. so if you see one of those, it's not you, it's TakTuk. π«Ά
π SEE ALSO π
tatkuk(1), TakTuk(3), TakTuk::Pilot(3)
π AUTHOR π
the original concept of TakTuk has been proposed by Cyrille Martin in his PhD thesis. people involved in this work include Jacques Briat, Olivier Richard, Thierry Gautier and Guillaume Huard. academic slay. π
the author of the version 3 (perl version) and current maintainer of the package is Guillaume Huard.
π COPYRIGHT π
the taktukcomm communication interface library is provided under the terms of the GNU General Public License version 2 or later.
and that's the whole page, bestie! this was perl v5.40.1, dated 2025-09-30, and it's been real. go forth and multicast responsibly. πβ¨π¦
π¦ where this page comes from
- ubuntu resolute: libtaktuk-1-dev 3.7.8-1 Β· GPL-2.0-or-later
- ubuntu stonking: libtaktuk-1-dev 3.7.8-1 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms