diff options
Diffstat (limited to 'src/platform/windows/win_pipe.c')
| -rw-r--r-- | src/platform/windows/win_pipe.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/platform/windows/win_pipe.c b/src/platform/windows/win_pipe.c index f254d9bb..22886faa 100644 --- a/src/platform/windows/win_pipe.c +++ b/src/platform/windows/win_pipe.c @@ -9,6 +9,7 @@ #include "core/nng_impl.h" +#include <stdio.h> // Windows named pipes won't work for us; we *MUST* use sockets. This is // a real sadness, but what can you do. We use an anonymous socket bound // to localhost and a connected peer. @@ -34,19 +35,21 @@ nni_plat_pipe_open(int *wfdp, int *rfdp) // ephemeral port. addr.sin_family = AF_INET; addr.sin_port = 0; - addr.sin_addr.s_addr = INADDR_LOOPBACK; + addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); afd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (afd == INVALID_SOCKET) { goto fail; } + // Make sure we have exclusive address use... one = 1; if (setsockopt(afd, SOL_SOCKET, SO_EXCLUSIVEADDRUSE, (char *) (&one), sizeof (one)) != 0) { goto fail; } + alen = sizeof (addr); if (bind(afd, (struct sockaddr *) &addr, alen) != 0) { goto fail; @@ -65,7 +68,6 @@ nni_plat_pipe_open(int *wfdp, int *rfdp) if (afd == INVALID_SOCKET) { goto fail; } - if (connect(rfd, (struct sockaddr *) &addr, alen) != 0) { goto fail; } @@ -105,7 +107,7 @@ fail: closesocket(wfd); } - return (0); + return (rv); } |
