--- libev/ev.3 2007/12/25 07:16:53 1.59 +++ libev/ev.3 2008/01/28 12:23:02 1.60 @@ -1,4 +1,4 @@ -.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.35 +.\" Automatically generated by Pod::Man 2.16 (Pod::Simple 3.05) .\" .\" Standard preamble: .\" ======================================================================== @@ -25,11 +25,11 @@ .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left -.\" double quote, and \*(R" will give a right double quote. | will give a -.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to -.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C' -.\" expand to `' in nroff, nothing in troff, for use with C<>. -.tr \(*W-|\(bv\*(Tr +.\" double quote, and \*(R" will give a right double quote. \*(C+ will +.\" give a nicer C++. Capital omega is used to do unbreakable dashes and +.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, +.\" nothing in troff, for use with C<>. +.tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- @@ -48,22 +48,25 @@ . ds R" '' 'br\} .\" +.\" Escape single quotes in literal strings from groff's Unicode transform. +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. -.if \nF \{\ +.ie \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} -.\" -.\" For nroff, turn off justification. Always turn off hyphenation; it makes -.\" way too many mistakes in technical documents. -.hy 0 -.if n .na +.el \{\ +. de IX +.. +.\} .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. @@ -129,7 +132,11 @@ .\" ======================================================================== .\" .IX Title "EV 1" -.TH EV 1 "2007-12-25" "perl v5.8.8" "User Contributed Perl Documentation" +.TH EV 1 "2008-01-28" "perl v5.10.0" "User Contributed Perl Documentation" +.\" For nroff, turn off justification. Always turn off hyphenation; it makes +.\" way too many mistakes in technical documents. +.if n .ad l +.nh .SH "NAME" libev \- a high performance full\-featured event loop written in C .SH "SYNOPSIS" @@ -141,14 +148,10 @@ .IX Subsection "EXAMPLE PROGRAM" .Vb 1 \& #include -.Ve -.PP -.Vb 2 +\& \& ev_io stdin_watcher; \& ev_timer timeout_watcher; -.Ve -.PP -.Vb 8 +\& \& /* called when data readable on stdin */ \& static void \& stdin_cb (EV_P_ struct ev_io *w, int revents) @@ -157,42 +160,30 @@ \& ev_io_stop (EV_A_ w); /* just a syntax example */ \& ev_unloop (EV_A_ EVUNLOOP_ALL); /* leave all loop calls */ \& } -.Ve -.PP -.Vb 6 +\& \& static void \& timeout_cb (EV_P_ struct ev_timer *w, int revents) \& { \& /* puts ("timeout"); */ \& ev_unloop (EV_A_ EVUNLOOP_ONE); /* leave one loop call */ \& } -.Ve -.PP -.Vb 4 +\& \& int \& main (void) \& { \& struct ev_loop *loop = ev_default_loop (0); -.Ve -.PP -.Vb 3 +\& \& /* initialise an io watcher, then start it */ \& ev_io_init (&stdin_watcher, stdin_cb, /*STDIN_FILENO*/ 0, EV_READ); \& ev_io_start (loop, &stdin_watcher); -.Ve -.PP -.Vb 3 -\& /* simple non-repeating 5.5 second timeout */ +\& +\& /* simple non\-repeating 5.5 second timeout */ \& ev_timer_init (&timeout_watcher, timeout_cb, 5.5, 0.); \& ev_timer_start (loop, &timeout_watcher); -.Ve -.PP -.Vb 2 +\& \& /* loop till timeout or data ready */ \& ev_loop (loop, 0); -.Ve -.PP -.Vb 2 +\& \& return 0; \& } .Ve @@ -315,7 +306,7 @@ .IP "unsigned int ev_embeddable_backends ()" 4 .IX Item "unsigned int ev_embeddable_backends ()" Returns the set of backends that are embeddable in other event loops. This -is the theoretical, all\-platform, value. To find which backends +is the theoretical, all-platform, value. To find which backends might be supported on the current system, you would need to look at \&\f(CW\*(C`ev_embeddable_backends () & ev_supported_backends ()\*(C'\fR, likewise for recommended ones. @@ -344,20 +335,14 @@ \& for (;;) \& { \& void *newptr = realloc (ptr, size); -.Ve -.Sp -.Vb 2 +\& \& if (newptr) \& return newptr; -.Ve -.Sp -.Vb 3 +\& \& sleep (60); \& } \& } -.Ve -.Sp -.Vb 2 +\& \& ... \& ev_set_allocator (persistent_realloc); .Ve @@ -380,9 +365,7 @@ \& perror (msg); \& abort (); \& } -.Ve -.Sp -.Vb 2 +\& \& ... \& ev_set_syserr_cb (fatal_error); .Ve @@ -408,6 +391,13 @@ If you don't know what event loop to use, use the one returned from this function. .Sp +The default loop is the only loop that can handle \f(CW\*(C`ev_signal\*(C'\fR and +\&\f(CW\*(C`ev_child\*(C'\fR watchers, and to do this, it always registers a handler +for \f(CW\*(C`SIGCHLD\*(C'\fR. If this is a problem for your app you can either +create a dynamic loop with \f(CW\*(C`ev_loop_new\*(C'\fR that doesn't do that, or you +can simply overwrite the \f(CW\*(C`SIGCHLD\*(C'\fR signal handler \fIafter\fR calling +\&\f(CW\*(C`ev_default_init\*(C'\fR. +.Sp The flags argument can be used to specify special behaviour or specific backends to use, and is usually specified as \f(CW0\fR (or \f(CW\*(C`EVFLAG_AUTO\*(C'\fR). .Sp @@ -454,7 +444,7 @@ libev tries to roll its own fd_set with no limits on the number of fds, but if that fails, expect a fairly low limit on the number of fds when using this backend. It doesn't scale too well (O(highest_fd)), but its -usually the fastest backend for a low number of (low\-numbered :) fds. +usually the fastest backend for a low number of (low-numbered :) fds. .Sp To get good performance out of this backend you need a high amount of parallelity (most of the file descriptors should be busy). If you are @@ -549,6 +539,10 @@ file descriptor per loop iteration. For small and medium numbers of file descriptors a \*(L"slow\*(R" \f(CW\*(C`EVBACKEND_SELECT\*(C'\fR or \f(CW\*(C`EVBACKEND_POLL\*(C'\fR backend might perform better. +.Sp +On the positive side, ignoring the spurious readyness notifications, this +backend actually performed to specification in all tests and is fully +embeddable, which is a rare feat among the OS-specific backends. .ie n .IP """EVBACKEND_ALL""" 4 .el .IP "\f(CWEVBACKEND_ALL\fR" 4 .IX Item "EVBACKEND_ALL" @@ -561,9 +555,8 @@ .RS 4 .Sp If one or more of these are ored into the flags value, then only these -backends will be tried (in the reverse order as given here). If none are -specified, most compiled-in backend will be tried, usually in reverse -order of their flag values :) +backends will be tried (in the reverse order as listed here). If none are +specified, all backends in \f(CW\*(C`ev_recommended_backends ()\*(C'\fR will be tried. .Sp The most typical usage is like this: .Sp @@ -625,14 +618,16 @@ earlier call to \f(CW\*(C`ev_loop_new\*(C'\fR. .IP "ev_default_fork ()" 4 .IX Item "ev_default_fork ()" -This function reinitialises the kernel state for backends that have -one. Despite the name, you can call it anytime, but it makes most sense -after forking, in either the parent or child process (or both, but that -again makes little sense). -.Sp -You \fImust\fR call this function in the child process after forking if and -only if you want to use the event library in both processes. If you just -fork+exec, you don't have to call it. +This function sets a flag that causes subsequent \f(CW\*(C`ev_loop\*(C'\fR iterations +to reinitialise the kernel state for backends that have one. Despite the +name, you can call it anytime, but it makes most sense after forking, in +the child process (or both child and parent, but that again makes little +sense). You \fImust\fR call it in the child before using any of the libev +functions, and it will only take effect at the next \f(CW\*(C`ev_loop\*(C'\fR iteration. +.Sp +On the other hand, you only need to call this function in the child +process if and only if you want to use the event library in the child. If +you just fork+exec, you don't have to call it at all. .Sp The function itself is quite fast and it's usually not a problem to call it just in case after a fork. To make this easy, the function will fit in @@ -641,10 +636,6 @@ .Vb 1 \& pthread_atfork (0, 0, ev_default_fork); .Ve -.Sp -At the moment, \f(CW\*(C`EVBACKEND_SELECT\*(C'\fR and \f(CW\*(C`EVBACKEND_POLL\*(C'\fR are safe to use -without calling this function, so if you force one of those backends you -do not need to care. .IP "ev_loop_fork (loop)" 4 .IX Item "ev_loop_fork (loop)" Like \f(CW\*(C`ev_default_fork\*(C'\fR, but acts on an event loop created by @@ -699,29 +690,34 @@ .Sp Here are the gory details of what \f(CW\*(C`ev_loop\*(C'\fR does: .Sp -.Vb 19 -\& - Before the first iteration, call any pending watchers. -\& * If there are no active watchers (reference count is zero), return. -\& - Queue all prepare watchers and then call all outstanding watchers. -\& - If we have been forked, recreate the kernel state. -\& - Update the kernel state with all outstanding changes. -\& - Update the "event loop time". -\& - Calculate for how long to block. -\& - Block the process, waiting for any events. -\& - Queue all outstanding I/O (fd) events. -\& - Update the "event loop time" and do time jump handling. -\& - Queue all outstanding timers. -\& - Queue all outstanding periodics. -\& - If no events are pending now, queue all idle watchers. -\& - Queue all check watchers. -\& - Call all queued watchers in reverse order (i.e. check watchers first). +.Vb 10 +\& \- Before the first iteration, call any pending watchers. +\& * If EVFLAG_FORKCHECK was used, check for a fork. +\& \- If a fork was detected, queue and call all fork watchers. +\& \- Queue and call all prepare watchers. +\& \- If we have been forked, recreate the kernel state. +\& \- Update the kernel state with all outstanding changes. +\& \- Update the "event loop time". +\& \- Calculate for how long to sleep or block, if at all +\& (active idle watchers, EVLOOP_NONBLOCK or not having +\& any active watchers at all will result in not sleeping). +\& \- Sleep if the I/O and timer collect interval say so. +\& \- Block the process, waiting for any events. +\& \- Queue all outstanding I/O (fd) events. +\& \- Update the "event loop time" and do time jump handling. +\& \- Queue all outstanding timers. +\& \- Queue all outstanding periodics. +\& \- If no events are pending now, queue all idle watchers. +\& \- Queue all check watchers. +\& \- Call all queued watchers in reverse order (i.e. check watchers first). \& Signals and child watchers are implemented as I/O watchers, and will \& be handled here by queueing them when their watcher gets executed. -\& - If ev_unloop has been called or EVLOOP_ONESHOT or EVLOOP_NONBLOCK -\& were used, return, otherwise continue with step *. +\& \- If ev_unloop has been called, or EVLOOP_ONESHOT or EVLOOP_NONBLOCK +\& were used, or there are no active watchers, return, otherwise +\& continue with step *. .Ve .Sp -Example: Queue some jobs and then loop until no events are outsanding +Example: Queue some jobs and then loop until no events are outstanding anymore. .Sp .Vb 4 @@ -736,6 +732,8 @@ has processed all outstanding events). The \f(CW\*(C`how\*(C'\fR argument must be either \&\f(CW\*(C`EVUNLOOP_ONE\*(C'\fR, which will make the innermost \f(CW\*(C`ev_loop\*(C'\fR call return, or \&\f(CW\*(C`EVUNLOOP_ALL\*(C'\fR, which will make all nested \f(CW\*(C`ev_loop\*(C'\fR calls return. +.Sp +This \*(L"unloop state\*(R" will be cleared when entering \f(CW\*(C`ev_loop\*(C'\fR again. .IP "ev_ref (loop)" 4 .IX Item "ev_ref (loop)" .PD 0 @@ -751,7 +749,9 @@ visible to the libev user and should not keep \f(CW\*(C`ev_loop\*(C'\fR from exiting if no event watchers registered by it are active. It is also an excellent way to do this for generic recurring timers or from within third-party -libraries. Just remember to \fIunref after start\fR and \fIref before stop\fR. +libraries. Just remember to \fIunref after start\fR and \fIref before stop\fR +(but only if the watcher wasn't active before, or was active before, +respectively). .Sp Example: Create a signal watcher, but keep it from keeping \f(CW\*(C`ev_loop\*(C'\fR running when nothing else is active. @@ -818,9 +818,7 @@ \& ev_io_stop (w); \& ev_unloop (loop, EVUNLOOP_ALL); \& } -.Ve -.PP -.Vb 6 +\& \& struct ev_loop *loop = ev_default_loop (0); \& struct ev_io stdin_watcher; \& ev_init (&stdin_watcher, my_cb); @@ -1091,23 +1089,19 @@ .PP .Vb 1 \& #include -.Ve -.PP -.Vb 6 +\& \& static void \& t1_cb (EV_P_ struct ev_timer *w, int revents) \& { \& struct my_biggy big = (struct my_biggy * -\& (((char *)w) - offsetof (struct my_biggy, t1)); +\& (((char *)w) \- offsetof (struct my_biggy, t1)); \& } -.Ve -.PP -.Vb 6 +\& \& static void \& t2_cb (EV_P_ struct ev_timer *w, int revents) \& { \& struct my_biggy big = (struct my_biggy * -\& (((char *)w) - offsetof (struct my_biggy, t2)); +\& (((char *)w) \- offsetof (struct my_biggy, t2)); \& } .Ve .SH "WATCHER TYPES" @@ -1223,8 +1217,11 @@ .IX Item "int events [read-only]" The events being watched. .PP +\fIExamples\fR +.IX Subsection "Examples" +.PP Example: Call \f(CW\*(C`stdin_readable_cb\*(C'\fR when \s-1STDIN_FILENO\s0 has become, well -readable, but only once. Since it is likely line\-buffered, you could +readable, but only once. Since it is likely line-buffered, you could attempt to read a whole line in the callback. .PP .Vb 6 @@ -1232,11 +1229,9 @@ \& stdin_readable_cb (struct ev_loop *loop, struct ev_io *w, int revents) \& { \& ev_io_stop (loop, w); -\& .. read from stdin here (or from w->fd) and haqndle any I/O errors +\& .. read from stdin here (or from w\->fd) and haqndle any I/O errors \& } -.Ve -.PP -.Vb 6 +\& \& ... \& struct ev_loop *loop = ev_default_init (0); \& struct ev_io stdin_readable; @@ -1263,7 +1258,7 @@ on the current time, use something like this to adjust for this: .PP .Vb 1 -\& ev_timer_set (&timer, after + ev_now () - ev_time (), 0.); +\& ev_timer_set (&timer, after + ev_now () \- ev_time (), 0.); .Ve .PP The callback is guarenteed to be invoked only when its timeout has passed, @@ -1317,10 +1312,10 @@ \& ev_timer_init (timer, callback, 0., 5.); \& ev_timer_again (loop, timer); \& ... -\& timer->again = 17.; +\& timer\->again = 17.; \& ev_timer_again (loop, timer); \& ... -\& timer->again = 10.; +\& timer\->again = 10.; \& ev_timer_again (loop, timer); .Ve .Sp @@ -1332,6 +1327,9 @@ or \f(CW\*(C`ev_timer_again\*(C'\fR is called and determines the next timeout (if any), which is also when any modifications are taken into account. .PP +\fIExamples\fR +.IX Subsection "Examples" +.PP Example: Create a timer that fires after 60 seconds. .PP .Vb 5 @@ -1340,9 +1338,7 @@ \& { \& .. one minute over, w is actually stopped right here \& } -.Ve -.PP -.Vb 3 +\& \& struct ev_timer mytimer; \& ev_timer_init (&mytimer, one_minute_cb, 60., 0.); \& ev_timer_start (loop, &mytimer); @@ -1357,16 +1353,12 @@ \& { \& .. ten seconds without any activity \& } -.Ve -.PP -.Vb 4 +\& \& struct ev_timer mytimer; \& ev_timer_init (&mytimer, timeout_cb, 0., 10.); /* note, only repeat used */ \& ev_timer_again (&mytimer); /* start timer */ \& ev_loop (loop, 0); -.Ve -.PP -.Vb 3 +\& \& // and in some piece of code that gets executed on any "activity": \& // reset the timeout to start ticking again at 10 seconds \& ev_timer_again (&mytimer); @@ -1404,14 +1396,16 @@ Lots of arguments, lets sort it out... There are basically three modes of operation, and we will explain them from simplest to complex: .RS 4 -.IP "* absolute timer (at = time, interval = reschedule_cb = 0)" 4 -.IX Item "absolute timer (at = time, interval = reschedule_cb = 0)" +.IP "\(bu" 4 +absolute timer (at = time, interval = reschedule_cb = 0) +.Sp In this configuration the watcher triggers an event at the wallclock time \&\f(CW\*(C`at\*(C'\fR and doesn't repeat. It will not adjust when a time jump occurs, that is, if it is to be run at January 1st 2011 then it will run when the system time reaches or surpasses this time. -.IP "* non-repeating interval timer (at = offset, interval > 0, reschedule_cb = 0)" 4 -.IX Item "non-repeating interval timer (at = offset, interval > 0, reschedule_cb = 0)" +.IP "\(bu" 4 +non-repeating interval timer (at = offset, interval > 0, reschedule_cb = 0) +.Sp In this mode the watcher will always be scheduled to time out at the next \&\f(CW\*(C`at + N * interval\*(C'\fR time (for some integer N, which can also be negative) and then repeat, regardless of any time jumps. @@ -1435,8 +1429,9 @@ For numerical stability it is preferable that the \f(CW\*(C`at\*(C'\fR value is near \&\f(CW\*(C`ev_now ()\*(C'\fR (the current time), but there is no range requirement for this value. -.IP "* manual reschedule mode (at and interval ignored, reschedule_cb = callback)" 4 -.IX Item "manual reschedule mode (at and interval ignored, reschedule_cb = callback)" +.IP "\(bu" 4 +manual reschedule mode (at and interval ignored, reschedule_cb = callback) +.Sp In this mode the values for \f(CW\*(C`interval\*(C'\fR and \f(CW\*(C`at\*(C'\fR are both being ignored. Instead, each time the periodic watcher gets scheduled, the reschedule callback will be called with the watcher as first, and the @@ -1501,6 +1496,9 @@ When active, contains the absolute time that the watcher is supposed to trigger next. .PP +\fIExamples\fR +.IX Subsection "Examples" +.PP Example: Call a callback every hour, or, more precisely, whenever the system clock is divisible by 3600. The callback invocation times have potentially a lot of jittering, but good long-term stability. @@ -1511,9 +1509,7 @@ \& { \& ... its now a full hour (UTC, or TAI or whatever your clock follows) \& } -.Ve -.PP -.Vb 3 +\& \& struct ev_periodic hourly_tick; \& ev_periodic_init (&hourly_tick, clock_cb, 0., 3600., 0); \& ev_periodic_start (loop, &hourly_tick); @@ -1523,17 +1519,13 @@ .PP .Vb 1 \& #include -.Ve -.PP -.Vb 5 +\& \& static ev_tstamp \& my_scheduler_cb (struct ev_periodic *w, ev_tstamp now) \& { \& return fmod (now, 3600.) + 3600.; \& } -.Ve -.PP -.Vb 1 +\& \& ev_periodic_init (&hourly_tick, clock_cb, 0., 0., my_scheduler_cb); .Ve .PP @@ -1581,18 +1573,20 @@ .PP \fIWatcher-Specific Functions and Data Members\fR .IX Subsection "Watcher-Specific Functions and Data Members" -.IP "ev_child_init (ev_child *, callback, int pid)" 4 -.IX Item "ev_child_init (ev_child *, callback, int pid)" +.IP "ev_child_init (ev_child *, callback, int pid, int trace)" 4 +.IX Item "ev_child_init (ev_child *, callback, int pid, int trace)" .PD 0 -.IP "ev_child_set (ev_child *, int pid)" 4 -.IX Item "ev_child_set (ev_child *, int pid)" +.IP "ev_child_set (ev_child *, int pid, int trace)" 4 +.IX Item "ev_child_set (ev_child *, int pid, int trace)" .PD Configures the watcher to wait for status changes of process \f(CW\*(C`pid\*(C'\fR (or \&\fIany\fR process if \f(CW\*(C`pid\*(C'\fR is specified as \f(CW0\fR). The callback can look at the \f(CW\*(C`rstatus\*(C'\fR member of the \f(CW\*(C`ev_child\*(C'\fR watcher structure to see the status word (use the macros from \f(CW\*(C`sys/wait.h\*(C'\fR and see your systems \&\f(CW\*(C`waitpid\*(C'\fR documentation). The \f(CW\*(C`rpid\*(C'\fR member contains the pid of the -process causing the status change. +process causing the status change. \f(CW\*(C`trace\*(C'\fR must be either \f(CW0\fR (only +activate the watcher when the process terminates) or \f(CW1\fR (additionally +activate the watcher when the process is stopped or continued). .IP "int pid [read\-only]" 4 .IX Item "int pid [read-only]" The process id this watcher watches out for, or \f(CW0\fR, meaning any process id. @@ -1604,6 +1598,9 @@ The process exit/trace status caused by \f(CW\*(C`rpid\*(C'\fR (see your systems \&\f(CW\*(C`waitpid\*(C'\fR and \f(CW\*(C`sys/wait.h\*(C'\fR documentation for details). .PP +\fIExamples\fR +.IX Subsection "Examples" +.PP Example: Try to exit cleanly on \s-1SIGINT\s0 and \s-1SIGTERM\s0. .PP .Vb 5 @@ -1612,9 +1609,7 @@ \& { \& ev_unloop (loop, EVUNLOOP_ALL); \& } -.Ve -.PP -.Vb 3 +\& \& struct ev_signal signal_watcher; \& ev_signal_init (&signal_watcher, sigint_cb, SIGINT); \& ev_signal_start (loop, &sigint_cb); @@ -1646,7 +1641,7 @@ .PP This watcher type is not meant for massive numbers of stat watchers, as even with OS-supported change notifications, this can be -resource\-intensive. +resource-intensive. .PP At the time of this writing, only the Linux inotify interface is implemented (implementing kqueue support is left as an exercise for the @@ -1736,30 +1731,26 @@ .PP Example: Watch \f(CW\*(C`/etc/passwd\*(C'\fR for attribute changes. .PP -.Vb 15 +.Vb 10 \& static void \& passwd_cb (struct ev_loop *loop, ev_stat *w, int revents) \& { \& /* /etc/passwd changed in some way */ -\& if (w->attr.st_nlink) +\& if (w\->attr.st_nlink) \& { -\& printf ("passwd current size %ld\en", (long)w->attr.st_size); -\& printf ("passwd current atime %ld\en", (long)w->attr.st_mtime); -\& printf ("passwd current mtime %ld\en", (long)w->attr.st_mtime); +\& printf ("passwd current size %ld\en", (long)w\->attr.st_size); +\& printf ("passwd current atime %ld\en", (long)w\->attr.st_mtime); +\& printf ("passwd current mtime %ld\en", (long)w\->attr.st_mtime); \& } \& else \& /* you shalt not abuse printf for puts */ \& puts ("wow, /etc/passwd is not there, expect problems. " \& "if this is windows, they already arrived\en"); \& } -.Ve -.PP -.Vb 2 +\& \& ... \& ev_stat passwd; -.Ve -.PP -.Vb 2 +\& \& ev_stat_init (&passwd, passwd_cb, "/etc/passwd", 0.); \& ev_stat_start (loop, &passwd); .Ve @@ -1772,30 +1763,22 @@ .Vb 2 \& static ev_stat passwd; \& static ev_timer timer; -.Ve -.PP -.Vb 4 +\& \& static void \& timer_cb (EV_P_ ev_timer *w, int revents) \& { \& ev_timer_stop (EV_A_ w); -.Ve -.PP -.Vb 2 -\& /* now it's one second after the most recent passwd change */ +\& +\& /* now it\*(Aqs one second after the most recent passwd change */ \& } -.Ve -.PP -.Vb 6 +\& \& static void \& stat_cb (EV_P_ ev_stat *w, int revents) \& { -\& /* reset the one-second timer */ +\& /* reset the one\-second timer */ \& ev_timer_again (EV_A_ &timer); \& } -.Ve -.PP -.Vb 4 +\& \& ... \& ev_stat_init (&passwd, stat_cb, "/etc/passwd", 0.); \& ev_stat_start (loop, &passwd); @@ -1820,7 +1803,7 @@ .PP Apart from keeping your process non-blocking (which is a useful effect on its own sometimes), idle watchers are a good place to do -\&\*(L"pseudo\-background processing\*(R", or delay processing stuff to after the +\&\*(L"pseudo-background processing\*(R", or delay processing stuff to after the event loop has handled all outstanding events. .PP \fIWatcher-Specific Functions and Data Members\fR @@ -1831,6 +1814,9 @@ kind. There is a \f(CW\*(C`ev_idle_set\*(C'\fR macro, but using it is utterly pointless, believe me. .PP +\fIExamples\fR +.IX Subsection "Examples" +.PP Example: Dynamically allocate an \f(CW\*(C`ev_idle\*(C'\fR watcher, start it, and in the callback, free it. Also, use no error checking, as usual. .PP @@ -1840,11 +1826,9 @@ \& { \& free (w); \& // now do something you wanted to do when the program has -\& // no longer asnything immediate to do. +\& // no longer anything immediate to do. \& } -.Ve -.PP -.Vb 3 +\& \& struct ev_idle *idle_watcher = malloc (sizeof (struct ev_idle)); \& ev_idle_init (idle_watcher, idle_cb); \& ev_idle_start (loop, idle_cb); @@ -1896,7 +1880,7 @@ too) should not activate (\*(L"feed\*(R") events into libev. While libev fully supports this, they will be called before other \f(CW\*(C`ev_check\*(C'\fR watchers did their job. As \f(CW\*(C`ev_check\*(C'\fR watchers are often used to embed other -(non\-libev) event loops those other event loops might be in an unusable +(non-libev) event loops those other event loops might be in an unusable state until their \f(CW\*(C`ev_check\*(C'\fR watcher ran (always remind yourself to coexist peacefully with others). .PP @@ -1912,6 +1896,9 @@ parameters of any kind. There are \f(CW\*(C`ev_prepare_set\*(C'\fR and \f(CW\*(C`ev_check_set\*(C'\fR macros, but using them is utterly, utterly and completely pointless. .PP +\fIExamples\fR +.IX Subsection "Examples" +.PP There are a number of principal ways to embed other event loops or modules into libev. Here are some ideas on how to include libadns into libev (there is a Perl module named \f(CW\*(C`EV::ADNS\*(C'\fR that does this, which you could @@ -1928,16 +1915,12 @@ .Vb 2 \& static ev_io iow [nfd]; \& static ev_timer tw; -.Ve -.PP -.Vb 4 +\& \& static void \& io_cb (ev_loop *loop, ev_io *w, int revents) \& { \& } -.Ve -.PP -.Vb 8 +\& \& // create io watchers for each fd and a timer before blocking \& static void \& adns_prepare_cb (ev_loop *loop, ev_prepare *w, int revents) @@ -1946,56 +1929,42 @@ \& struct pollfd fds [nfd]; \& // actual code will need to loop here and realloc etc. \& adns_beforepoll (ads, fds, &nfd, &timeout, timeval_from (ev_time ())); -.Ve -.PP -.Vb 3 -\& /* the callback is illegal, but won't be called as we stop during check */ -\& ev_timer_init (&tw, 0, timeout * 1e-3); +\& +\& /* the callback is illegal, but won\*(Aqt be called as we stop during check */ +\& ev_timer_init (&tw, 0, timeout * 1e\-3); \& ev_timer_start (loop, &tw); -.Ve -.PP -.Vb 6 +\& \& // create one ev_io per pollfd \& for (int i = 0; i < nfd; ++i) \& { \& ev_io_init (iow + i, io_cb, fds [i].fd, \& ((fds [i].events & POLLIN ? EV_READ : 0) \& | (fds [i].events & POLLOUT ? EV_WRITE : 0))); -.Ve -.PP -.Vb 4 +\& \& fds [i].revents = 0; \& ev_io_start (loop, iow + i); \& } \& } -.Ve -.PP -.Vb 5 +\& \& // stop all watchers after blocking \& static void \& adns_check_cb (ev_loop *loop, ev_check *w, int revents) \& { \& ev_timer_stop (loop, &tw); -.Ve -.PP -.Vb 8 +\& \& for (int i = 0; i < nfd; ++i) \& { \& // set the relevant poll flags \& // could also call adns_processreadable etc. here \& struct pollfd *fd = fds + i; \& int revents = ev_clear_pending (iow + i); -\& if (revents & EV_READ ) fd->revents |= fd->events & POLLIN; -\& if (revents & EV_WRITE) fd->revents |= fd->events & POLLOUT; -.Ve -.PP -.Vb 3 +\& if (revents & EV_READ ) fd\->revents |= fd\->events & POLLIN; +\& if (revents & EV_WRITE) fd\->revents |= fd\->events & POLLOUT; +\& \& // now stop the watcher \& ev_io_stop (loop, iow + i); \& } -.Ve -.PP -.Vb 2 +\& \& adns_afterpoll (adns, fds, nfd, timeval_from (ev_now (loop)); \& } .Ve @@ -2011,30 +1980,22 @@ \& static void \& timer_cb (EV_P_ ev_timer *w, int revents) \& { -\& adns_state ads = (adns_state)w->data; +\& adns_state ads = (adns_state)w\->data; \& update_now (EV_A); -.Ve -.PP -.Vb 2 +\& \& adns_processtimeouts (ads, &tv_now); \& } -.Ve -.PP -.Vb 5 +\& \& static void \& io_cb (EV_P_ ev_io *w, int revents) \& { -\& adns_state ads = (adns_state)w->data; +\& adns_state ads = (adns_state)w\->data; \& update_now (EV_A); -.Ve -.PP -.Vb 3 -\& if (revents & EV_READ ) adns_processreadable (ads, w->fd, &tv_now); -\& if (revents & EV_WRITE) adns_processwriteable (ads, w->fd, &tv_now); +\& +\& if (revents & EV_READ ) adns_processreadable (ads, w\->fd, &tv_now); +\& if (revents & EV_WRITE) adns_processwriteable (ads, w\->fd, &tv_now); \& } -.Ve -.PP -.Vb 1 +\& \& // do not ever call adns_afterpoll .Ve .PP @@ -2049,36 +2010,24 @@ \& event_poll_func (GPollFD *fds, guint nfds, gint timeout) \& { \& int got_events = 0; -.Ve -.PP -.Vb 2 +\& \& for (n = 0; n < nfds; ++n) \& // create/start io watcher that sets the relevant bits in fds[n] and increment got_events -.Ve -.PP -.Vb 2 +\& \& if (timeout >= 0) \& // create/start timer -.Ve -.PP -.Vb 2 +\& \& // poll \& ev_loop (EV_A_ 0); -.Ve -.PP -.Vb 3 +\& \& // stop timer again \& if (timeout >= 0) \& ev_timer_stop (EV_A_ &to); -.Ve -.PP -.Vb 3 -\& // stop io watchers again - their callbacks should have set +\& +\& // stop io watchers again \- their callbacks should have set \& for (n = 0; n < nfds; ++n) \& ev_io_stop (EV_A_ iow [n]); -.Ve -.PP -.Vb 2 +\& \& return got_events; \& } .Ve @@ -2132,32 +2081,7 @@ So when you want to use this feature you will always have to be prepared that you cannot get an embeddable loop. The recommended way to get around this is to have a separate variables for your embeddable loop, try to -create it, and if that fails, use the normal loop for everything: -.PP -.Vb 3 -\& struct ev_loop *loop_hi = ev_default_init (0); -\& struct ev_loop *loop_lo = 0; -\& struct ev_embed embed; -.Ve -.PP -.Vb 5 -\& // see if there is a chance of getting one that works -\& // (remember that a flags value of 0 means autodetection) -\& loop_lo = ev_embeddable_backends () & ev_recommended_backends () -\& ? ev_loop_new (ev_embeddable_backends () & ev_recommended_backends ()) -\& : 0; -.Ve -.PP -.Vb 8 -\& // if we got one, then embed it, otherwise default to loop_hi -\& if (loop_lo) -\& { -\& ev_embed_init (&embed, 0, loop_lo); -\& ev_embed_start (loop_hi, &embed); -\& } -\& else -\& loop_lo = loop_hi; -.Ve +create it, and if that fails, use the normal loop for everything. .PP \fIWatcher-Specific Functions and Data Members\fR .IX Subsection "Watcher-Specific Functions and Data Members" @@ -2180,6 +2104,59 @@ .IP "struct ev_loop *other [read\-only]" 4 .IX Item "struct ev_loop *other [read-only]" The embedded event loop. +.PP +\fIExamples\fR +.IX Subsection "Examples" +.PP +Example: Try to get an embeddable event loop and embed it into the default +event loop. If that is not possible, use the default loop. The default +loop is stored in \f(CW\*(C`loop_hi\*(C'\fR, while the mebeddable loop is stored in +\&\f(CW\*(C`loop_lo\*(C'\fR (which is \f(CW\*(C`loop_hi\*(C'\fR in the acse no embeddable loop can be +used). +.PP +.Vb 3 +\& struct ev_loop *loop_hi = ev_default_init (0); +\& struct ev_loop *loop_lo = 0; +\& struct ev_embed embed; +\& +\& // see if there is a chance of getting one that works +\& // (remember that a flags value of 0 means autodetection) +\& loop_lo = ev_embeddable_backends () & ev_recommended_backends () +\& ? ev_loop_new (ev_embeddable_backends () & ev_recommended_backends ()) +\& : 0; +\& +\& // if we got one, then embed it, otherwise default to loop_hi +\& if (loop_lo) +\& { +\& ev_embed_init (&embed, 0, loop_lo); +\& ev_embed_start (loop_hi, &embed); +\& } +\& else +\& loop_lo = loop_hi; +.Ve +.PP +Example: Check if kqueue is available but not recommended and create +a kqueue backend for use with sockets (which usually work with any +kqueue implementation). Store the kqueue/socket\-only event loop in +\&\f(CW\*(C`loop_socket\*(C'\fR. (One might optionally use \f(CW\*(C`EVFLAG_NOENV\*(C'\fR, too). +.PP +.Vb 3 +\& struct ev_loop *loop = ev_default_init (0); +\& struct ev_loop *loop_socket = 0; +\& struct ev_embed embed; +\& +\& if (ev_supported_backends () & ~ev_recommended_backends () & EVBACKEND_KQUEUE) +\& if ((loop_socket = ev_loop_new (EVBACKEND_KQUEUE)) +\& { +\& ev_embed_init (&embed, 0, loop_socket); +\& ev_embed_start (loop, &embed); +\& } +\& +\& if (!loop_socket) +\& loop_socket = loop; +\& +\& // now use loop_socket for all sockets, and loop for everything else +.Ve .ie n .Sh """ev_fork"" \- the audacity to resume the event loop after a fork" .el .Sh "\f(CWev_fork\fP \- the audacity to resume the event loop after a fork" .IX Subsection "ev_fork - the audacity to resume the event loop after a fork" @@ -2231,9 +2208,7 @@ \& else if (revents & EV_READ) \& /* stdin might have data for us, joy! */; \& } -.Ve -.Sp -.Vb 1 +\& \& ev_once (STDIN_FILENO, EV_READ, 10., stdin_ready, 0); .Ve .IP "ev_feed_event (ev_loop *, watcher *, int revents)" 4 @@ -2253,20 +2228,24 @@ .IX Header "LIBEVENT EMULATION" Libev offers a compatibility emulation layer for libevent. It cannot emulate the internals of libevent, so here are some usage hints: -.IP "* Use it by including , as usual." 4 -.IX Item "Use it by including , as usual." -.PD 0 -.IP "* The following members are fully supported: ev_base, ev_callback, ev_arg, ev_fd, ev_res, ev_events." 4 -.IX Item "The following members are fully supported: ev_base, ev_callback, ev_arg, ev_fd, ev_res, ev_events." -.IP "* Avoid using ev_flags and the EVLIST_*\-macros, while it is maintained by libev, it does not work exactly the same way as in libevent (consider it a private \s-1API\s0)." 4 -.IX Item "Avoid using ev_flags and the EVLIST_*-macros, while it is maintained by libev, it does not work exactly the same way as in libevent (consider it a private API)." -.IP "* Priorities are not currently supported. Initialising priorities will fail and all watchers will have the same priority, even though there is an ev_pri field." 4 -.IX Item "Priorities are not currently supported. Initialising priorities will fail and all watchers will have the same priority, even though there is an ev_pri field." -.IP "* Other members are not supported." 4 -.IX Item "Other members are not supported." -.IP "* The libev emulation is \fInot\fR \s-1ABI\s0 compatible to libevent, you need to use the libev header file and library." 4 -.IX Item "The libev emulation is not ABI compatible to libevent, you need to use the libev header file and library." -.PD +.IP "\(bu" 4 +Use it by including , as usual. +.IP "\(bu" 4 +The following members are fully supported: ev_base, ev_callback, +ev_arg, ev_fd, ev_res, ev_events. +.IP "\(bu" 4 +Avoid using ev_flags and the EVLIST_*\-macros, while it is +maintained by libev, it does not work exactly the same way as in libevent (consider +it a private \s-1API\s0). +.IP "\(bu" 4 +Priorities are not currently supported. Initialising priorities +will fail and all watchers will have the same priority, even though there +is an ev_pri field. +.IP "\(bu" 4 +Other members are not supported. +.IP "\(bu" 4 +The libev emulation is \fInot\fR \s-1ABI\s0 compatible to libevent, you need +to use the libev header file and library. .SH "\*(C+ SUPPORT" .IX Header " SUPPORT" Libev comes with some simplistic wrapper classes for \*(C+ that mainly allow @@ -2356,9 +2335,7 @@ \& { \& void io_cb (ev::io &w, int revents) { } \& } -.Ve -.Sp -.Vb 3 +\& \& myclass obj; \& ev::io iow; \& iow.set (&obj); @@ -2419,25 +2396,17 @@ .Vb 4 \& class myclass \& { -\& ev_io io; void io_cb (ev::io &w, int revents); -\& ev_idle idle void idle_cb (ev::idle &w, int revents); -.Ve -.PP -.Vb 2 -\& myclass (); -\& } -.Ve -.PP -.Vb 4 -\& myclass::myclass (int fd) -\& { -\& io .set (this); -\& idle.set (this); -.Ve -.PP -.Vb 2 -\& io.start (fd, ev::READ); -\& } +\& ev::io io; void io_cb (ev::io &w, int revents); +\& ev:idle idle void idle_cb (ev::idle &w, int revents); +\& +\& myclass (int fd) +\& { +\& io .set (this); +\& idle.set (this); +\& +\& io.start (fd, ev::READ); +\& } +\& }; .Ve .SH "MACRO MAGIC" .IX Header "MACRO MAGIC" @@ -2472,9 +2441,7 @@ .Vb 2 \& // this is how ev_unref is being declared \& static void ev_unref (EV_P); -.Ve -.Sp -.Vb 2 +\& \& // this is how you can declare your typical callback \& static void cb (EV_P_ ev_timer *w, int revents) .Ve @@ -2497,9 +2464,7 @@ \& { \& ev_check_stop (EV_A_ w); \& } -.Ve -.PP -.Vb 4 +\& \& ev_check check; \& ev_check_init (&check, check_cb); \& ev_check_start (EV_DEFAULT_ &check); @@ -2510,7 +2475,7 @@ Libev can (and often is) directly embedded into host applications. Examples of applications that embed it include the Deliantra Game Server, the \s-1EV\s0 perl module, the \s-1GNU\s0 Virtual Private Ethernet (gvpe) -and rxvt\-unicode. +and rxvt-unicode. .PP The goal is to enable you to just copy the necessary files into your source directory without having to change even a single line in them, so @@ -2555,13 +2520,9 @@ \& ev.c \& ev_vars.h \& ev_wrap.h -.Ve -.PP -.Vb 1 +\& \& ev_win32.c required on win32 platforms only -.Ve -.PP -.Vb 5 +\& \& ev_select.c only when select backend is enabled (which is enabled by default) \& ev_poll.c only when poll backend is enabled (disabled by default) \& ev_epoll.c only when the epoll backend is enabled (disabled by default) @@ -2666,6 +2627,13 @@ \&\f(CW\*(C`_get_osfhandle\*(C'\fR on the fd to convert it to an \s-1OS\s0 handle. Otherwise, it is assumed that all these functions actually work on fds, even on win32. Should not be defined on non\-win32 platforms. +.IP "\s-1EV_FD_TO_WIN32_HANDLE\s0" 4 +.IX Item "EV_FD_TO_WIN32_HANDLE" +If \f(CW\*(C`EV_SELECT_IS_WINSOCKET\*(C'\fR is enabled, then libev needs a way to map +file descriptors to socket handles. When not defining this symbol (the +default), then libev will call \f(CW\*(C`_get_osfhandle\*(C'\fR, which is usually +correct. In some cases, programs use their own file descriptor management, +in which case they can provide this function to map fds to socket handles. .IP "\s-1EV_USE_POLL\s0" 4 .IX Item "EV_USE_POLL" If defined to be \f(CW1\fR, libev will compile in support for the \f(CW\*(C`poll\*(C'\fR(2) @@ -2705,8 +2673,8 @@ .IP "\s-1EV_H\s0" 4 .IX Item "EV_H" The name of the \fIev.h\fR header file used to include it. The default if -undefined is \f(CW"ev.h"\fR in \fIevent.h\fR and \fIev.c\fR. This can be used to -virtually rename the \fIev.h\fR header file in case of conflicts. +undefined is \f(CW"ev.h"\fR in \fIevent.h\fR, \fIev.c\fR and \fIev++.h\fR. This can be +used to virtually rename the \fIev.h\fR header file in case of conflicts. .IP "\s-1EV_CONFIG_H\s0" 4 .IX Item "EV_CONFIG_H" If \f(CW\*(C`EV_STANDALONE\*(C'\fR isn't \f(CW1\fR, this variable can be used to override @@ -2715,7 +2683,7 @@ .IP "\s-1EV_EVENT_H\s0" 4 .IX Item "EV_EVENT_H" Similarly to \f(CW\*(C`EV_H\*(C'\fR, this macro can be used to override \fIevent.c\fR's idea -of how the \fIevent.h\fR header can be found, the dfeault is \f(CW"event.h"\fR. +of how the \fIevent.h\fR header can be found, the default is \f(CW"event.h"\fR. .IP "\s-1EV_PROTOTYPES\s0" 4 .IX Item "EV_PROTOTYPES" If defined to be \f(CW0\fR, then \fIev.h\fR will not define any function @@ -2820,25 +2788,25 @@ If you need to re-export the \s-1API\s0 (e.g. via a dll) and you need a list of exported symbols, you can use the provided \fISymbol.*\fR files which list all public symbols, one per line: -.Sp +.PP .Vb 2 \& Symbols.ev for libev proper \& Symbols.event for the libevent emulation .Ve -.Sp +.PP This can also be used to rename all public symbols to avoid clashes with multiple versions of libev linked together (which is obviously bad in itself, but sometimes it is inconvinient to avoid this). -.Sp +.PP A sed command like this will create wrapper \f(CW\*(C`#define\*(C'\fR's that you need to include before including \fIev.h\fR: -.Sp +.PP .Vb 1 -\& wrap.h +\& wrap.h .Ve -.Sp +.PP This would create a file \fIwrap.h\fR which essentially looks like this: -.Sp +.PP .Vb 4 \& #define ev_backend myprefix_ev_backend \& #define ev_check_start myprefix_ev_check_start @@ -2854,10 +2822,10 @@ interface) and \fI\s-1EV\s0.xs\fR (implementation) files. Only the \fI\s-1EV\s0.xs\fR file will be compiled. It is pretty complex because it provides its own header file. -.Sp +.PP The usage in rxvt-unicode is simpler. It has a \fIev_cpp.h\fR header file that everybody includes and which overrides some configure choices: -.Sp +.PP .Vb 9 \& #define EV_MINIMAL 1 \& #define EV_USE_POLL 0 @@ -2868,14 +2836,12 @@ \& #define EV_CONFIG_H \& #define EV_MINPRI 0 \& #define EV_MAXPRI 0 -.Ve -.Sp -.Vb 1 +\& \& #include "ev++.h" .Ve -.Sp +.PP And a \fIev_cpp.C\fR implementation file that contains libev proper and is compiled: -.Sp +.PP .Vb 2 \& #include "ev_cpp.h" \& #include "ev.c" @@ -2885,13 +2851,12 @@ In this section the complexities of (many of) the algorithms used inside libev will be explained. For complexity discussions about backends see the documentation for \f(CW\*(C`ev_default_init\*(C'\fR. -.Sp +.PP All of the following are about amortised time: If an array needs to be extended, libev needs to realloc and move the whole array, but this happens asymptotically never with higher number of elements, so O(1) might mean it might do a lengthy realloc operation in rare cases, but on average it is much faster and asymptotically approaches constant time. -.RS 4 .IP "Starting and stopping timer/periodic watchers: O(log skipped_other_timers)" 4 .IX Item "Starting and stopping timer/periodic watchers: O(log skipped_other_timers)" This means that, when you have a watcher that triggers in one hour and @@ -2932,8 +2897,73 @@ priority. When doing priority-based operations, libev usually has to linearly search all the priorities, but starting/stopping and activating watchers becomes O(1) w.r.t. prioritiy handling. -.RE -.RS 4 +.SH "Win32 platform limitations and workarounds" +.IX Header "Win32 platform limitations and workarounds" +Win32 doesn't support any of the standards (e.g. \s-1POSIX\s0) that libev +requires, and its I/O model is fundamentally incompatible with the \s-1POSIX\s0 +model. Libev still offers limited functionality on this platform in +the form of the \f(CW\*(C`EVBACKEND_SELECT\*(C'\fR backend, and only supports socket +descriptors. This only applies when using Win32 natively, not when using +e.g. cygwin. +.PP +There is no supported compilation method available on windows except +embedding it into other applications. +.PP +Due to the many, low, and arbitrary limits on the win32 platform and the +abysmal performance of winsockets, using a large number of sockets is not +recommended (and not reasonable). If your program needs to use more than +a hundred or so sockets, then likely it needs to use a totally different +implementation for windows, as libev offers the \s-1POSIX\s0 model, which cannot +be implemented efficiently on windows (microsoft monopoly games). +.IP "The winsocket select function" 4 +.IX Item "The winsocket select function" +The winsocket \f(CW\*(C`select\*(C'\fR function doesn't follow \s-1POSIX\s0 in that it requires +socket \fIhandles\fR and not socket \fIfile descriptors\fR. This makes select +very inefficient, and also requires a mapping from file descriptors +to socket handles. See the discussion of the \f(CW\*(C`EV_SELECT_USE_FD_SET\*(C'\fR, +\&\f(CW\*(C`EV_SELECT_IS_WINSOCKET\*(C'\fR and \f(CW\*(C`EV_FD_TO_WIN32_HANDLE\*(C'\fR preprocessor +symbols for more info. +.Sp +The configuration for a \*(L"naked\*(R" win32 using the microsoft runtime +libraries and raw winsocket select is: +.Sp +.Vb 2 +\& #define EV_USE_SELECT 1 +\& #define EV_SELECT_IS_WINSOCKET 1 /* forces EV_SELECT_USE_FD_SET, too */ +.Ve +.Sp +Note that winsockets handling of fd sets is O(n), so you can easily get a +complexity in the O(nA\*^X) range when using win32. +.IP "Limited number of file descriptors" 4 +.IX Item "Limited number of file descriptors" +Windows has numerous arbitrary (and low) limits on things. Early versions +of winsocket's select only supported waiting for a max. of \f(CW64\fR handles +(probably owning to the fact that all windows kernels can only wait for +\&\f(CW64\fR things at the same time internally; microsoft recommends spawning a +chain of threads and wait for 63 handles and the previous thread in each). +.Sp +Newer versions support more handles, but you need to define \f(CW\*(C`FD_SETSIZE\*(C'\fR +to some high number (e.g. \f(CW2048\fR) before compiling the winsocket select +call (which might be in libev or elsewhere, for example, perl does its own +select emulation on windows). +.Sp +Another limit is the number of file descriptors in the microsoft runtime +libraries, which by default is \f(CW64\fR (there must be a hidden \fI64\fR fetish +or something like this inside microsoft). You can increase this by calling +\&\f(CW\*(C`_setmaxstdio\*(C'\fR, which can increase this limit to \f(CW2048\fR (another +arbitrary limit), but is broken in many versions of the microsoft runtime +libraries. +.Sp +This might get you to about \f(CW512\fR or \f(CW2048\fR sockets (depending on +windows version and/or the phase of the moon). To get more, you need to +wrap all I/O functions and provide your own fd management, but the cost of +calling select (O(nA\*^X)) will likely make this unworkable. .SH "AUTHOR" .IX Header "AUTHOR" Marc Lehmann . +.SH "POD ERRORS" +.IX Header "POD ERRORS" +Hey! \fBThe above document had some coding errors, which are explained below:\fR +.IP "Around line 2686:" 4 +.IX Item "Around line 2686:" +You forgot a '=back' before '=head2'