Binding Libev to Digitalmars' D

Marc Lehmann schmorp at schmorp.de
Tue Jun 3 06:29:52 CEST 2008


On Tue, Jun 03, 2008 at 02:08:46PM +1000, Chris Hulbert <chris.hulbert at gmail.com> wrote:
> When it runs, I get the following error:
> 
> Assertion failure: '("libev only supports socket fds in this
> configuration", ioctlsocket (anfd->handle, FIONREAD, &argp)
>  == 0)' on line 710 in file 'ev.c'

Windows is completely incompatible with the posix model of having readyness
notifications - only sockets work, and evry badly at that. It is extremely
unlikely that non-blocking code works "as-is" on windows.

libev works around *some* of those issues (for example, the CVS version
works around windows' non-blocking connect failing to wake up the program
on errors), but of course not on others (close() not working for sockets,
connect returning EINPROGRESS meaning it failed, send not supporting
partial writes, only being able to do one non-blocking operation at a time
and more and more etc.).

It's a completely, utterly, broken platform.

So in general, code on windows needs "largish'ish" changes independent of
libev to have any chance of working reliably.

Since I suspected lots of grief otherwise, libev actively checks that the
file descriptor you pass in belongs to a socket.

Note that:

a) low-level operating system handles are not file descriptors
b) the raw socket functions return operating system handles

The reason for this is that libev offers the _same_ API on windows as on
portable/standards compliant operating systems: you have to apss in file
descriptors on unix, you have to pass in file descriptors on windows.

The most likely causes for the above error are either:

a) you pass in an operating system handle instead of a file descriptor
b) you pass in some file descriptor that isn't a socket (e.g.
   standard input)

> Can anyone suggest where I'm going wrong - are my #define statements
> wrong in the myev.c ?

The defines can make libev use posix-select or winsock select, but the
API is the same: you need to pass in file descriptors, and those file
descriptors must belong to sockets.

(And again: libev does what it can, but your code likely has to change for
windows, too).

-- 
                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_              http://www.deliantra.net
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      pcg at goof.com
      -=====/_/_//_/\_,_/ /_/\_\



More information about the libev mailing list