3 Mux, muxinit, muxrpc, muxthreads \- protocol multiplexor
15 int (*settag)(Mux *mux, void *msg, uint tag);
16 int (*gettag)(Mux *mux, void *msg);
17 int (*send)(Mux *mux, void *msg);
18 void *(*recv)(Mux *mux);
21 \&... /* private fields follow */
26 void muxinit(Mux *mux);
29 void* muxrpc(Mux *mux, void *request);
32 void muxprocs(Mux *mux);
35 is a generic protocol multiplexor.
36 A client program initializes a
38 structure with information about the protocol
39 (mainly in the form of helper functions)
42 to execute individual RPCs without worrying
43 about details of multiplexing requests
44 and demultiplexing responses.
47 assumes that the protocol messages contain a
49 (or message ID) field that exists for the sole purpose of demultiplexing messages.
51 chooses the tags and then calls a helper function
52 to put them in the outgoing messages.
54 calls another helper function to retrieve tags
55 from incoming messages.
56 It also calls helper functions to send and receive packets.
58 A client should allocate a
60 structure and then call
62 to initialize the library's private elements.
63 The client must initialize the following elements:
65 .I mintag\fR, \fPmaxtag
66 The range of valid tags;
68 is the maximum valid tag plus one, so that
70 is equal to the number of valid tags.
74 (all tags are being used for RPCs currently in progress),
77 will block until an executing call finishes.
79 .I settag\fR, \fPgettag
80 Set or get the tag value in a message.
83 Send or receive protocol messages on the connection.
85 should block until a message is available and
86 should return nil if the connection is closed.
88 will arrange that only one call to
93 An auxiliary pointer for use by the client.
95 Once a client has initialized the
97 structure, it can call
102 is the message passed to
106 The return value is the response packet,
110 nil if an error occurred.
126 in these procs instead of in the calling proc.
127 This is useful if the implementation of
130 blocks an entire proc
131 and there are other threads in the calling proc
132 that need to remain active.
135 .B \*9/src/lib9pclient/fs.c
136 for an example of using
149 does not know how to free protocol messages,
150 so message arriving with unexpected or invalid