aboutsummaryrefslogtreecommitdiff
path: root/src/platform/windows/win_pipe.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2017-01-22 02:32:32 -0800
committerGarrett D'Amore <garrett@damore.org>2017-01-22 02:32:32 -0800
commitb93d5759c9b39ff153a14d474d800cd981f7dc97 (patch)
tree1a98b7ac74cd91003c38f53ae3eb01fb8027deef /src/platform/windows/win_pipe.c
parent769f9a2b66aca629eb4dd240a072849a48aa300f (diff)
downloadnng-b93d5759c9b39ff153a14d474d800cd981f7dc97.tar.gz
nng-b93d5759c9b39ff153a14d474d800cd981f7dc97.tar.bz2
nng-b93d5759c9b39ff153a14d474d800cd981f7dc97.zip
Event notification via pollable FDs verified working.
Diffstat (limited to 'src/platform/windows/win_pipe.c')
-rw-r--r--src/platform/windows/win_pipe.c8
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);
}