On Sat, Jan 17, 2015 at 10:12 AM, Hanspeter Portner <[email protected]> wrote: > Hi > > I need to interface to dns_sd.h from libuv > (https://opensource.apple.com/tarballs/mDNSResponder/) across platforms > (Linux, OSX, Windows). > > dns_sd.h returns a file handle (int fd) which I need to poll to get updates > from the dns_sd server. This works fine on Linux/OSX, but not so on Windows. > dns_sd.h apparently returns a file handle to a TCP socket (to localhost) on > Windows and a Unix socket on Linux/OSX. > > Here (http://docs.libuv.org/en/v1.x/poll.html) I read: > Note On windows only sockets can be polled with poll handles. On Unix any > file descriptor that would be accepted by poll(2) can be used. > > I have attached a minimal program which should show the issue: > According to the docs the program should succeed as the file handle on > Windows refers to a TCP socket, but it triggers a ENOTSOCK error. > Likewise, the uv_guess_handle returns UV_UNKNOWN_HANDLE. > > Do I misread the docs, or why is this not working? > I cross compile both libuv and libdns_sd from Linux, if it should matter... > > > test.c > -------------------------------------- > #include <uv.h> > #include <stdio.h> > > #if defined(_WIN32) > # define AF_MDNS AF_INET > #else > # define AF_MDNS AF_LOCAL > #endif > > int > main(int argc, char **argv) > { > uv_loop_t *loop = uv_default_loop(); > > printf("AF: %i\n", AF_MDNS); > int fd = socket(AF_MDNS, SOCK_STREAM, 0); > printf("fd: %i %i\n", fd, uv_guess_handle(fd)); > > uv_poll_t poller; > > int err; > if((err = uv_poll_init(loop, &poller, fd))) > fprintf(stderr, "uv_poll_init: %s\n", uv_strerror(err)); > > return 0; > } > > Makefile > ----------------------------- > all: test test.exe > > test: test.c > gcc -o $@ $< -I/usr/include -L/usr/lib -luv > > test.exe: test.c > x86_64-w64-mingw32-gcc -static -static-libgcc -o $@ $< > -I/usr/x86_64-w64-mingw32/include -L/usr/x86_64-w64-mingw32/lib -luv > -lws2_32 -lpsapi -liphlpapi > > > Output Linux/OSX (x86_64) > --------------------------------------- > AF: 1 > fd: 9 7 > > Output Windows 7 (x86_64) > ---------------------------------------- > AF: 2 > fd: 80 0 > uv_poll_init: socket operation on non-socket
I'm not the libuv team's Windows expert but that looks like a bug to me. Do you want to file an issue? Does the socket work with uv_tcp_open() or uv_pipe_open()? -- You received this message because you are subscribed to the Google Groups "libuv" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/libuv. For more options, visit https://groups.google.com/d/optout.
