NAME
Mux, muxinit, muxrpc, muxthreads – protocol multiplexor |
SYNOPSIS
#include <mux.h>
struct Mux
void muxinit(Mux *mux);
void* muxrpc(Mux *mux, void *request);
void muxprocs(Mux *mux);
Muxrpc*muxrpcstart(Mux *mux, void *request);
void* muxrpccanfinish(Muxrpc *rpc); |
DESCRIPTION
Libmux is a generic protocol multiplexor. A client program initializes
a Mux structure with information about the protocol (mainly in
the form of helper functions) and can then use muxrpc to execute
individual RPCs without worrying about details of multiplexing
requests and demultiplexing responses. Libmux assumes that the protocol messages contain a tag (or message ID) field that exists for the sole purpose of demultiplexing messages. Libmux chooses the tags and then calls a helper function to put them in the outgoing messages. Libmux calls another helper function to retrieve tags from incoming messages. It also calls helper functions to send and receive packets.
A client should allocate a Mux structure and then call muxinit
to initialize the library's private elements. The client must
initialize the following elements:
|
EXAMPLE
See /sys/src/lib9pclient/fs.c for an example of using libmux with
9P (see intro(5)). |
SOURCE
/sys/src/libmux |
SEE ALSO
thread(2), intro(5) |
BUGS
Libmux does not know how to free protocol messages, so message
arriving with unexpected or invalid tags are leaked. |