TakTukComm - Interface to taktuk(1)
communication facilities
Perl interface:
$taktuk::error; taktuk::error_msg($);
taktuk::get($);
taktuk::send(%); taktuk::recv(%);
C interface:
#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 );
The TakTuk communication layer interfaces provide a way for programs
executed using the taktuk(1)
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. This interface
is available both for the Perl and the C langages.
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 logical peer (these processes might be several local commands or forked processes). Nevertheless, the C interface is thread-safe (it uses posix mutexes in its critical sections). These issues are likely to be addressed in future TakTuk versions.
The Perl communication interface for TakTuk is made of two functions that
can be called by scripts executed using the taktuk_perl
command of
TakTuk or using the TakTuk package provided with the TakTuk
distribution.
These two functions are:
taktuk(1)
for
informations about set specifications).
The two mandatory fields in the arguments are to
(with a set specification)
and body
. Returns an undefined value upon error.
timeout
argument with a numeric value.
Returns an empty list upon error.
When an error occur, both of these functions set the variable $taktuk::error
to the numeric code of the error that occured. 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::syswrite
failed. This is due to a syswrite
error
different than EAGAIN
. The code should be accessible using errno
.
taktuk::recv
only)sysread
failed (the code should be accessible using errno
).
taktuk::send
only)to
field missing in the arguments.
taktuk::send
only)body
field missing in the arguments.
taktuk::recv
only)taktuk::recv
timeouted. This only occur when giving a timeout
field as taktuk::recv
argument.
taktuk::send
only)taktuk::send
function is
not correct.
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 of communication functions and constants definitions can be found in
taktuk.h
also provided with the distribution.
The communication functions are:
miscellaneous functions
multicast send functions
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
buffer
made of length
bytes to dest
.
taktuk_sendv
is the vector variant of taktuk_send
(similar to
writev
system function).
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
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
.
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 :
write(2)
failed. The code should be accessible using errno
.
read(2)
failed. The code should be accessible using errno
.
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_get
is not a valid TakTuk field.
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
.
tatkuk(1)
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.