Mingw doesn't like write() to socket

Marc Lehmann schmorp at schmorp.de
Thu Nov 25 01:45:53 CET 2010

On Tue, Nov 23, 2010 at 12:58:29PM +0100, Bert Belder <H.Belder at student.TUDelft.NL> wrote:
> I'm trying to use libev in a MinGW project. Initially ev_async watchers
> didn't work; after some debugging I found out that the write() call in
> evpipe_write() always returns -1, indicating failure; apparently the
> MinGW libraries don't like me writing to a socket using write.

Actually, all the documentation I can find points to mingw supporting
read/write just fine.

If send relaly works instead of write, then most likely
EV_FD_TO_WIN32_HANDLEand the reverse are not working for mingw somehow.

> However swapping out the write call and replacing it with:
>   send(EV_FD_TO_WIN32_HANDLE(evpipe [1]), &dummy, 1, 0);
> actually solves my problems; select() suddenly wakes up.

Most likely it will cause other issues though - write on mingw should just
work on socket fds (not socket handles).

So the mystery is sitll there.

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

More information about the libev mailing list