From 78e51a8c6678b6e3dff3d619aa786669f531f4bc Mon Sep 17 00:00:00 2001 From: rsc Date: Fri, 14 Jan 2005 03:45:44 +0000 Subject: checkpoint --- man/man3/mux.html | 169 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 169 insertions(+) create mode 100644 man/man3/mux.html (limited to 'man/man3/mux.html') diff --git a/man/man3/mux.html b/man/man3/mux.html new file mode 100644 index 00000000..e3e7e4c8 --- /dev/null +++ b/man/man3/mux.html @@ -0,0 +1,169 @@ + +mux(3) - Plan 9 from User Space + + + + +
+
+
MUX(3)MUX(3) +
+
+

NAME
+ +
+ + Mux, muxinit, muxrpc, muxthreads – protocol multiplexor
+ +
+

SYNOPSIS
+ +
+ + #include <mux.h> +
+
+ struct Mux
+ {
+ +
+ + uint mintag;
+ uint maxtag;
+ int (*settag)(Mux *mux, void *msg, uint tag);
+ int (*gettag)(Mux *mux, void *msg);
+ int (*send)(Mux *mux, void *msg);
+ void *(*recv)(Mux *mux);
+ void *aux;
+ ... /* private fields follow */
+ +
+ };
+ +
+ + void    muxinit(Mux *mux);
+ +
+
+ void* muxrpc(Mux *mux, void *request);
+ +
+
+ void    muxprocs(Mux *mux);
+
+
+

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:
+ mintag, maxtag
+
+
+ + The range of valid tags; maxtag is the maximum valid tag plus + one, so that maxtagmintag is equal to the number of valid tags. + If libmux runs out of tags (all tags are being used for RPCs currently + in progress), a new call to muxrpc will block until an executing + call finishes.
+ +
+ settag, gettag
+
+
+ + Set or get the tag value in a message.
+ +
+ send, recv
+
+
+ + Send or receive protocol messages on the connection. Recv should + block until a message is available and should return nil if the + connection is closed. Libmux will arrange that only one call to + recv is active at a time.
+ +
+ aux   An auxiliary pointer for use by the client. Once a client has + initialized the Mux structure, it can call muxrpc to execute RPCs. + The request is the message passed to settag and send. The return + value is the response packet, as provided by recv, or nil if an + error occurred. Muxprocs allocates new procs (see + +
+ + thread(3)) in which to run send and recv. After a call to muxprocs, + muxrpc will run send and recv in these procs instead of in the + calling proc. This is useful if the implementation of either (particularly + recv) blocks an entire proc and there are other threads in the + calling proc that need to remain active. + +
+ +
+

EXAMPLE
+ +
+ + See /usr/local/plan9/src/lib9pclient/fs.c for an example of using + libmux with 9P (see intro(9p)).
+ +
+

SOURCE
+ +
+ + /usr/local/plan9/src/libmux
+
+
+

SEE ALSO
+ +
+ + thread(3), intro(9p)
+ +
+

BUGS
+ +
+ + Libmux does not know how to free protocol messages, so message + arriving with unexpected or invalid tags are leaked. +
+ + Using mintag other than zero is not well tested and probably buggy.
+ +
+ +

+
+
+ + +
+
+
+Space Glenda +
+
+ + -- cgit v1.2.3