ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libev/ev.pod
(Generate patch)

Comparing libev/ev.pod (file contents):
Revision 1.111 by root, Tue Dec 25 18:01:20 2007 UTC vs.
Revision 1.112 by root, Wed Dec 26 08:06:09 2007 UTC

2491be used is the winsock select). This means that it will call 2491be used is the winsock select). This means that it will call
2492C<_get_osfhandle> on the fd to convert it to an OS handle. Otherwise, 2492C<_get_osfhandle> on the fd to convert it to an OS handle. Otherwise,
2493it is assumed that all these functions actually work on fds, even 2493it is assumed that all these functions actually work on fds, even
2494on win32. Should not be defined on non-win32 platforms. 2494on win32. Should not be defined on non-win32 platforms.
2495 2495
2496=item EV_FD_TO_WIN32_HANDLE
2497
2498If C<EV_SELECT_IS_WINSOCKET> is enabled, then libev needs a way to map
2499file descriptors to socket handles. When not defining this symbol (the
2500default), then libev will call C<_get_osfhandle>, which is usually
2501correct. In some cases, programs use their own file descriptor management,
2502in which case they can provide this function to map fds to socket handles.
2503
2496=item EV_USE_POLL 2504=item EV_USE_POLL
2497 2505
2498If defined to be C<1>, libev will compile in support for the C<poll>(2) 2506If defined to be C<1>, libev will compile in support for the C<poll>(2)
2499backend. Otherwise it will be enabled on non-win32 platforms. It 2507backend. Otherwise it will be enabled on non-win32 platforms. It
2500takes precedence over select. 2508takes precedence over select.
2772watchers becomes O(1) w.r.t. prioritiy handling. 2780watchers becomes O(1) w.r.t. prioritiy handling.
2773 2781
2774=back 2782=back
2775 2783
2776 2784
2785=head1 Win32 platform limitations and workarounds
2786
2787Win32 doesn't support any of the standards (e.g. POSIX) that libev
2788requires, and its I/O model is fundamentally incompatible with the POSIX
2789model. Libev still offers limited functionality on this platform in
2790the form of the C<EVBACKEND_SELECT> backend, and only supports socket
2791descriptors. This only applies when using Win32 natively, not when using
2792e.g. cygwin.
2793
2794There is no supported compilation method available on windows except
2795embedding it into other applications.
2796
2797Due to the many, low, and arbitrary limits on the win32 platform and the
2798abysmal performance of winsockets, using a large number of sockets is not
2799recommended (and not reasonable). If your program needs to use more than
2800a hundred or so sockets, then likely it needs to use a totally different
2801implementation for windows, as libev offers the POSIX model, which cannot
2802be implemented efficiently on windows (microsoft monopoly games).
2803
2804=over 4
2805
2806=item The winsocket select function
2807
2808The winsocket C<select> function doesn't follow POSIX in that it requires
2809socket I<handles> and not socket I<file descriptors>. This makes select
2810very inefficient, and also requires a mapping from file descriptors
2811to socket handles. See the discussion of the C<EV_SELECT_USE_FD_SET>,
2812C<EV_SELECT_IS_WINSOCKET> and C<EV_FD_TO_WIN32_HANDLE> preprocessor
2813symbols for more info.
2814
2815The configuration for a "naked" win32 using the microsoft runtime
2816libraries and raw winsocket select is:
2817
2818 #define EV_USE_SELECT 1
2819 #define EV_SELECT_IS_WINSOCKET 1 /* forces EV_SELECT_USE_FD_SET, too */
2820
2821Note that winsockets handling of fd sets is O(n), so you can easily get a
2822complexity in the O(n²) range when using win32.
2823
2824=item Limited number of file descriptors
2825
2826Windows has numerous arbitrary (and low) limits on things. Early versions
2827of winsocket's select only supported waiting for a max. of C<64> handles
2828(probably owning to the fact that all windows kernels can only wait for
2829C<64> things at the same time internally; microsoft recommends spawning a
2830chain of threads and wait for 63 handles and the previous thread in each).
2831
2832Newer versions support more handles, but you need to define C<FD_SETSIZE>
2833to some high number (e.g. C<2048>) before compiling the winsocket select
2834call (which might be in libev or elsewhere, for example, perl does its own
2835select emulation on windows).
2836
2837Another limit is the number of file descriptors in the microsoft runtime
2838libraries, which by default is C<64> (there must be a hidden I<64> fetish
2839or something like this inside microsoft). You can increase this by calling
2840C<_setmaxstdio>, which can increase this limit to C<2048> (another
2841arbitrary limit), but is broken in many versions of the microsoft runtime
2842libraries.
2843
2844This might get you to about C<512> or C<2048> sockets (depending on
2845windows version and/or the phase of the moon). To get more, you need to
2846wrap all I/O functions and provide your own fd management, but the cost of
2847calling select (O(n²)) will likely make this unworkable.
2848
2849=back
2850
2851
2777=head1 AUTHOR 2852=head1 AUTHOR
2778 2853
2779Marc Lehmann <libev@schmorp.de>. 2854Marc Lehmann <libev@schmorp.de>.
2780 2855

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines