… | |
… | |
3326 | more than a hundred or so sockets, then likely it needs to use a totally |
3326 | more than a hundred or so sockets, then likely it needs to use a totally |
3327 | different implementation for windows, as libev offers the POSIX readiness |
3327 | different implementation for windows, as libev offers the POSIX readiness |
3328 | notification model, which cannot be implemented efficiently on windows |
3328 | notification model, which cannot be implemented efficiently on windows |
3329 | (Microsoft monopoly games). |
3329 | (Microsoft monopoly games). |
3330 | |
3330 | |
|
|
3331 | A typical way to use libev under windows is to embed it (see the embedding |
|
|
3332 | section for details) and use the following F<evwrap.h> header file instead |
|
|
3333 | of F<ev.h>: |
|
|
3334 | |
|
|
3335 | #define EV_STANDALONE /* keeps ev from requiring config.h */ |
|
|
3336 | #define EV_SELECT_IS_WINSOCKET 1 /* configure libev for windows select */ |
|
|
3337 | #define EV_STAT_ENABLE 0 /* no stat() availble */ |
|
|
3338 | |
|
|
3339 | #include "ev.h" |
|
|
3340 | |
|
|
3341 | And compile the following F<evwrap.c> file into your project (make sure |
|
|
3342 | you do I<not> compile the F<ev.c> or any other embedded soruce files!): |
|
|
3343 | |
|
|
3344 | #include "evwrap.h" |
|
|
3345 | #include "ev.c" |
|
|
3346 | |
3331 | =over 4 |
3347 | =over 4 |
3332 | |
3348 | |
3333 | =item The winsocket select function |
3349 | =item The winsocket select function |
3334 | |
3350 | |
3335 | The winsocket C<select> function doesn't follow POSIX in that it |
3351 | The winsocket C<select> function doesn't follow POSIX in that it |
3336 | requires socket I<handles> and not socket I<file descriptors> (it is |
3352 | requires socket I<handles> and not socket I<file descriptors> (it is |
3337 | also extremely buggy). This makes select very inefficient, and also |
3353 | also extremely buggy). This makes select very inefficient, and also |
3338 | requires a mapping from file descriptors to socket handles. See the |
3354 | requires a mapping from file descriptors to socket handles (the Microsoft |
|
|
3355 | C runtime provides the function C<_open_osfhandle> for this). See the |
3339 | discussion of the C<EV_SELECT_USE_FD_SET>, C<EV_SELECT_IS_WINSOCKET> and |
3356 | discussion of the C<EV_SELECT_USE_FD_SET>, C<EV_SELECT_IS_WINSOCKET> and |
3340 | C<EV_FD_TO_WIN32_HANDLE> preprocessor symbols for more info. |
3357 | C<EV_FD_TO_WIN32_HANDLE> preprocessor symbols for more info. |
3341 | |
3358 | |
3342 | The configuration for a "naked" win32 using the Microsoft runtime |
3359 | The configuration for a "naked" win32 using the Microsoft runtime |
3343 | libraries and raw winsocket select is: |
3360 | libraries and raw winsocket select is: |