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