chiark / gitweb /
Typo fixes.
[mLib] / man / selpk.3
CommitLineData
1e7e4330 1.\" -*-nroff-*-
2.TH selpk 3 "23 May 1999" mLib
3.SH NAME
4selpk \- packet-buffering input selector
5.\" @selpk_enable
6.\" @selpk_disable
7.\" @selpk_want
8.\" @selpk_init
9.\" @selpk_destroy
10.SH SYNOPSIS
11.nf
12.B "#include <mLib/selpk.h>"
13
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 ,
19.BI " int " fd ,
20.BI " void (*" func ")(octet *" b ", size_t " sz ", pkbuf *" pk ,
21.BI " size_t *" keep ", void *" p ),
22.BI " void *" p );
23.BI "void selpk_destroy(selpk *" b );
24.fi
25.SH DESCRIPTION
26The
27.B selpk
28subsystem is a selector which integrates with the
29.BR sel (3)
30system for I/O multiplexing. It reads packets from a file descriptor
31and passes them to a caller-defined function. It uses the packet buffer
32described in
33.BR pkbuf (3)
34to do its work: you should read about it in order to understand exactly
35how the packet buffer decides how much data is in each packet and the
36exact rules about what your packet handling function should and
37shouldn't do.
38.PP
39The data for a packet selector is stored in an object of type
40.BR selpk .
41This object must be allocated by the caller, and initialized using the
42.B selpk_init
43function. This requires a fair few arguments:
44.TP
45.BI "selpk *" pk
46Pointer to the
47.B selpk
48object to initialize.
49.TP
50.BI "sel_state *" s
51Pointer to a multiplexor object (type
52.BR sel_state )
53to which this selector should be attached. See
54.BR sel (3)
55for more details about multiplexors, and how this whole system works.
56.TP
57.BI "int " fd
58The file descriptor of the stream the selector should read from.
59.TP
60.nf
61.BI "void (*" func ")(octet *" b ", size_t " sz ", pkbuf *" p ,
62.BI " size_t *" keep ", void *" p )
63.fi
64The
65.I "packet handler"
66function. It is passed a pointer to each packet read from the file (or
67null to indicate end-of-file) and an arbitrary pointer (the
68.I p
69argument to
70.B selpk_init
71described below).
72.TP
73.BI "void *" p
74A pointer argument passed to
75.I func
76for each packet read from the file. Apart from this, the pointer is not
77used at all.
78.PP
79The
80.B selpk
81selector is immediately active. Subsequent calls to
82.B sel_select
83on the same multiplexor will cause any packets read from the file to be
84passed to your handling function. This function can at any time call
85.B selpk_disable
86to stop itself from being called any more. The selector is then
87disengaged from the I/O multiplexor and won't do anything until
88.B selpk_enable
89is called. Note that
90.B selpk_enable
91may well immediately start emitting complete packets of text which were
92queued up from the last I/O operation: it doesn't necessarily wait for
93the next
94.B sel_select
95call.
96.PP
97The size of packets read by the buffer is set by calling
98.BR selpk_want .
99See
100.BR pkbuf (3)
101for more details about how packet buffering works.
102.PP
103When it's finished with, a packet selector must be destroyed by calling
104.BR selpk_destroy .
105.SH "SEE ALSO"
106.BR pkbuf (3),
107.BR sel (3),
108.BR selbuf (3),
109.BR mLib (3).
110.SH AUTHOR
111Mark Wooding, <mdw@nsict.org>