Windows Compilation problem

Horacio Sanson hsanson at
Thu Jun 26 03:28:43 CEST 2008

On Fri, Jun 6, 2008 at 9:35 AM, Chris Hulbert <chris.hulbert at> wrote:
> FYI, i just had the same problem.
> To convert from a socket to a file descriptor, you'll need to use this function:
>  // for win32: convert from socket to file descriptor
>  // //
>  int fd = _open_osfhandle(socket,0);

I just encounter this same error but I am unable to solve it. My
program can create a socket() and actually connect to the server using
connect() but when I start the libev default loop an assertion ocurrs
when it calls _get_osfhandle() on line 716 of ev.c file.

How exactly am I supposed to use the _open_osfhandle() method as you
mention here?? If I use this method on the socket I get from the
socket() method then all subsequent calls on the socket (i.e. connect,
bind, listen) would return WSAENOTSOCK error.

Shall I replace all instances of _get_osfhandle() with a call to
_open_sofhandle()??  or am I missing something else??


> On Thu, Jun 5, 2008 at 6:23 PM, Marc Lehmann <schmorp at> wrote:
>> On Wed, Jun 04, 2008 at 04:29:46PM -0700, Matt Tolton <matt at> wrote:
>>> Any pointers here?  The fd that I'm using is a socket obtained from
>>> the winsock socket() call.  Here is the code used to initialize it:
>> That doesn't work - the libev API requires file descriptors on all
>> platforms.  What you pass in is a native opertaing system handle that is
>> not a file descriptor.
> _______________________________________________
> libev mailing list
> libev at

More information about the libev mailing list