2 .TH selpk 3 "23 May 1999" "Straylight/Edgeware" "mLib utilities library"
4 selpk \- packet-buffering input selector
12 .B "#include <mLib/selpk.h>"
14 .BI "void selpk_enable(selpk *" pk );
15 .BI "void selpk_disable(selpk *" pk );
16 .BI "void selpk_want(selpk *" pk ", size_t " sz );
17 .BI "void selpk_init(selpk *" pk ,
18 .BI " sel_state *" s ,
20 .BI " void (*" func ")(octet *" b ", size_t " sz ", pkbuf *" pk ,
21 .BI " size_t *" keep ", void *" p ),
23 .BI "void selpk_destroy(selpk *" b );
28 subsystem is a selector which integrates with the
30 system for I/O multiplexing. It reads packets from a file descriptor
31 and passes them to a caller-defined function. It uses the packet buffer
34 to do its work: you should read about it in order to understand exactly
35 how the packet buffer decides how much data is in each packet and the
36 exact rules about what your packet handling function should and
39 The data for a packet selector is stored in an object of type
41 This object must be allocated by the caller, and initialized using the
43 function. This requires a fair few arguments:
51 Pointer to a multiplexor object (type
53 to which this selector should be attached. See
55 for more details about multiplexors, and how this whole system works.
58 The file descriptor of the stream the selector should read from.
61 .BI "void (*" func ")(octet *" b ", size_t " sz ", pkbuf *" p ,
62 .BI " size_t *" keep ", void *" p )
66 function. It is passed a pointer to each packet read from the file (or
67 null to indicate end-of-file) and an arbitrary pointer (the
74 A pointer argument passed to
76 for each packet read from the file. Apart from this, the pointer is not
81 selector is immediately active. Subsequent calls to
83 on the same multiplexor will cause any packets read from the file to be
84 passed to your handling function. This function can at any time call
86 to stop itself from being called any more. The selector is then
87 disengaged from the I/O multiplexor and won't do anything until
91 may well immediately start emitting complete packets of text which were
92 queued up from the last I/O operation: it doesn't necessarily wait for
97 The size of packets read by the buffer is set by calling
101 for more details about how packet buffering works.
103 When it's finished with, a packet selector must be destroyed by calling
111 Mark Wooding, <mdw@nsict.org>