X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/mLib/blobdiff_plain/b78d1e6d0c48905d2b32a5019f7d5aef3119ae51..471f9daa24ee9251730e234fe92ad65c1fa9dff3:/man/sel.3 diff --git a/man/sel.3 b/man/sel.3 index e1dd9ee..6574ca0 100644 --- a/man/sel.3 +++ b/man/sel.3 @@ -1,10 +1,11 @@ .\" -*-nroff-*- -.TH sel 3 "22 May 1999" mLib +.TH sel 3 "22 May 1999" "Straylight/Edgeware" "mLib utilities library" .SH NAME sel \- low level interface for waiting for I/O .\" @sel_init .\" @sel_initfile .\" @sel_addfile +.\" @sel_force .\" @sel_rmfile .\" @sel_addtimer .\" @sel_rmtimer @@ -23,6 +24,7 @@ sel \- low level interface for waiting for I/O .BI " void (*" func ")(int " fd ", unsigned " mode ", void *" p ), .BI " void *" p ); .BI "void sel_addfile(sel_file *" f ); +.BI "void sel_force(sel_file *" f ); .BI "void sel_rmfile(sel_file *" f ); .BI "void sel_addtimer(sel_state *" s ", sel_timer *" t , @@ -110,6 +112,7 @@ interface. For examples, see and .BR conn (3). .SH "PROGRAMMING INTERFACE" +.SS "Multiplexors" A multiplexor is represented using the type .B sel_state defined in the @@ -129,7 +132,7 @@ initialization, addition to multiplexor, and removal from a multiplexor. It's convenient to separate addition and removal from initialization because file selectors often get added and removed many times over during their lifetimes. -.PP +.SS "File selectors" A file selector is initialized by the .B sel_initfile function. This requires a large number of arguments: @@ -192,6 +195,16 @@ the file descriptor for the file, a mode argument which describes the file's new condition, and the pointer argument set up at initialization time. .PP +The function +.B sel_force +will sometimes be useful while a +.B sel_select +call (see below) is in progress. It marks a file selector as being +ready even if it's not really. This is most useful when dynamically +adding a write selector: it's likely that the write will succeed +immediately, so it's worth trying. This will only work properly if +the write is non-blocking. +.PP The member .B fd of the @@ -199,7 +212,7 @@ of the structure is exported. It contains the file descriptor in which the selector is interested. You may not modify this value, but it's useful to be able to read it out \- it saves having to keep a copy. -.PP +.SS "Timer selectors" Timer selectors are simpler. There are only two operations provided on timer selectors: addition and removal. Initialization is performed as part of the addition operation. @@ -250,17 +263,17 @@ Note that timer events are a one-shot thing. Once they've happened, the timer selector is removed and the event can't happen again. This is normally what you want. Removing a timer is only useful (or safe!) before the timer event has been sent. -.PP +.SS "Performing I/O" Finally, the function .B sel_select is passed a multiplexor object. It waits for something interesting to happen, informs the appropriate selector handlers, and returns. If everything went according to plan, .B sel_select -returns zero. Otherwise it returns -1, and the global variable +returns zero. Otherwise it returns \-1, and the global variable .B errno is set appropriately. -.SH "SELECT HOOK FUNCTIONS" +.SS "Hook functions" In order to interface other I/O multiplexing systems to this one, it's possible to register .I hook @@ -373,6 +386,8 @@ though. .SH "SEE ALSO" .BR select (2), .BR poll (2), +.BR conn (3), +.BR selbuf (3), .BR mLib (3). .SH AUTHOR Mark Wooding,