[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [Libevent-users] Question on event-test.c sample program



On Sat, Jun 11, 2011 at 6:19 AM, Ed Day <edday2006@xxxxxxxxx> wrote:
> I see in the event-test.c sample program the disclaimer that it does
> not work on non-UNIX platforms (which to me means Windows, maybe
> others?).

Just Windows as far as I know.

>  It looks like this is an implementation of a named pipe.
> This has been a problem I have been trying to solve on Windows for
> awhile now, how to asynchronously read from named pipes and sockets in
> a standard read event loop.  Can libevent do this through the IOCP
> capability?

In theory, if the underlying file types support IOCP, then it
shouldn't be too hard to tweak the IOCP stuff to make it work.  The
iocp stuff right now is in the files bufferevent_async.c and
buffer_iocp.c and event_iocp.c.  There are at least three issues that
you'd need to address:
  1) The buffer_iocp.c code assumes that bytes are read/written with
WSASend and WSARecv.  But those only work with sockets: for named
pipes and named sockets, I think you need WriteFileEx or something?
Not sure there.
  2) The bufferevent_async_new() function and friends assumes that
they have an evutil_socket_t as input, whereas you'd probably want to
be passing in a HANDLE.
  3) Not nearly enough people have tested the IOCP stuff yet.  It
passes unit tests, and it seems to work for me, but if you use it, you
shouldn't be surprised to find at least one interesting bug.

If the bufferevent model isn't what you're going for here, and you
need the event model, you might take a look at Chris Davis's
"hybrid-loop2" branch.  I've uploaded it to my github repository,
since Chris's site seems to be down.  It tries to add support for
WaitForMultipleObjects-based polling in addition to select() polling.
According to Chris, it still needs a lot of work.

hth,
-- 
Nick
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.