taktukcomm

Langue: en

Version: 2009-04-04 (debian - 07/07/09)

Section: 3 (Bibliothèques de fonctions)

NAME

taktuk - Interface library to taktuk(1) communication facilities

SYNOPSIS

   #include <taktuk.h>
 
   const char *taktuk_error_msg(int msg_code);
 
   int taktuk_init_threads();
   int taktuk_leave_threads();
 
   int taktuk_get(char *field, long *value);
 
   int taktuk_multi_send(const char *dest, const void *buffer,
                                                          size_t length);
   int taktuk_multi_sendv(const char *dest, const struct iovec *iov,
                                                             int iovcnt);
 
   int taktuk_send(long dest, const void *buffer, size_t length);
   int taktuk_sendv(long dest, const struct iovec *iov, int iovcnt);
 
   int taktuk_recv(long *from, void *buffer, size_t *length, int timeout);
   int taktuk_recvv(long *from, const struct iovec *iov, int iovcnt,
                                                            int timeout);
 
   int taktuk_wait_message(long *from, size_t *size, int 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 provides a way for programs executed using the taktuk(1) command to exchange data. It is based on a simple send/receive model using multicast-like sends and optionally timeouted receives. This is only designed to be a control facility, in particular this is not a high performance communication library.

WARNING: the TakTuk communication interface is not process-safe : it is probably a very bad idea to use point-to-point communication in more than one process related to a single TakTuk instance (these processes might be several local commands or forked processes). Nevertheless, the C interface can be turned thread-safe by calling "taktuk_init_threads" (it uses posix mutexes in its critical sections).

Any program using TakTuk C communication interface has to link his program to the "taktuk" and "pthread" libraries (the "taktuk" library is provided with the distribution). Headers for communication functions and constants definitions can be found in "taktuk.h" also provided with the distribution.

The communication functions are:

miscellaneous functions

int taktuk_init_threads();
int taktuk_leave_threads();
functions to be called once in the process respectively before threads creation and after threads destruction if you want TakTuk C interface to be thread-safe.
int taktuk_get(char *field, long *result);
gets some information from TakTuk and places it into result. Currently available informations are ``rank'', ``count'', ``father'', ``child_min'' and ``child_max''. This is a better way to get these informations than environment variables as its takes into account renumbering that might occur after process spawn.

multicast send functions

int taktuk_multi_send(const char *dest, const void *buffer, size_t length);
int taktuk_multi_sendv(const char *dest, const struct iovec *iov, int iovcnt);
"taktuk_multi_send" sends the content of "buffer" made of "length" bytes to the set of target destinations "dest" (nul terminated characters string, see taktuk(1) for informations about set specifications). "taktuk_multi_sendv" is the vector variant of "taktuk_multi_send" (similar to "writev" system function).

single host send/recv functions

int taktuk_send(long dest, const void *buffer, size_t length);
int taktuk_sendv(long dest, const struct iovec *iov, int iovcnt);
sends the content of "buffer" made of "length" bytes to "dest". "taktuk_sendv" is the vector variant of "taktuk_send" (similar to "writev" system function).
int taktuk_recv(long *from, void *buffer, size_t *length, int timeout);
int taktuk_recvv(long *from, const struct iovec *iov, int iovcnt, int timeout);
blocks until the reception of a message. If a regular message is received, "taktuk_recv" sets the value of its arguments: "from" to the logical number of the sender, "buffer" to the data received wich is made of "length" bytes. If timeout is non nul, "taktuk_recv()" might receive a timeout notification. In this case, "taktuk_recv()" returns the TAKTUK_ETMOUT error code. "taktuk_recvv" is the vector variant of "taktuk_recv" (similar to "readv" system function).

WARNING: the buffer size should be sufficient to receive all the data of the matching send. If this is not the case, the program is likely to end up abruptly with a segmentation fault.

low-level recv functions

int taktuk_wait_message(long* from, size_t *size, int 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 be 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 read the data (using the size given by "taktuk_wait_message"). As other TakTuk receive functions, this function might return the TAKTUK_ETMOUT error code if "timeout" is not nul and expires before the reception.

If you don't know in advance the size of the data being sent to you, you can use these lower level functions. Actually, "taktuk_recv" is equivalent to a call to "taktuk_wait_message" followed by errors checks on buffer size and a call to "taktuk_read". This is the same for "taktuk_recvv".

RETURN VALUE

When an error occur, all of these functions return one of the following numeric error code. A textual description of the error is provided by the function "taktuk_error_msg()" that takes the error code as an argument.

Error codes are the following :

TAKTUK_ESWRIT
a call to write(2) failed. The code should be accessible using "errno".
TAKTUK_EFCLSD
the communication channel to the TakTuk engine has been closed. This typically occur when shutting down the logical network (using Ctrl-C on root node for instance).
TAKTUK_ESREAD (receives only)
a call to read(2) failed. The code should be accessible using "errno".
TAKTUK_ETMOUT (receives only)
The call to "taktuk_recv()" (or its vectorized equivalent) or to "taktuk_wait_message" timeouted. This only occur when giving a non nul "timeout" value to these functions.
TAKTUK_EALLOC
An internal memory allocation failure occured.
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 occur when launching a TakTuk program without using TakTuk.
TAKTUK_EINVAL (get only)
The field given to "taktuk_get" is 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 have also a textual description that is returned by "taktuk_error_msg".

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.

The author of the version 3 (perl version) and current maintainer of the package is Guillaume Huard.

The "taktukcomm" communication interface library is provided under the terms of the GNU General Public License version 2 or later.