Mingw doesn't like write() to socket
H.Belder at student.TUDelft.NL
Tue Nov 23 12:58:29 CET 2010
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.
Now there is this 'nice' comment above the write call:
/* win32 people keep sending patches that change this write() to
/* and then run away. but send() is wrong, it wants a socket handle on
/* so when you think this write should be a send instead, please find
/* where your send() is from - it's definitely not the microsoft send,
/* tell me. thank you. */
And I am confident that there are good reasons for doing things as they
However swapping out the write call and replacing it with:
send(EV_FD_TO_WIN32_HANDLE(evpipe ), &dummy, 1, 0);
actually solves my problems; select() suddenly wakes up.
Same story in pipecb():
recv(EV_FD_TO_WIN32_HANDLE(evpipe ), &dummy, 1, 0);
works for me where read() fails.
What are the odds that the read/write/send/recv calls can be wrapped in
an #ifdef __MINGW32__ so an unpatched libev will just work on MingW?
Thanks for your time.
More information about the libev