Mingw doesn't like write() to socket
Bert Belder
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
send() */
/* and then run away. but send() is wrong, it wants a socket handle on
win32 */
/* so when you think this write should be a send instead, please find
out */
/* where your send() is from - it's definitely not the microsoft send,
and */
/* tell me. thank you. */
And I am confident that there are good reasons for doing things as they
were done.
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.
Same story in pipecb():
recv(EV_FD_TO_WIN32_HANDLE(evpipe [0]), &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.
- Bert
More information about the libev
mailing list