From 9e921ed1e518ddcc27d6b1ddb0ad60b168bfebc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Tue, 8 Jul 2014 18:57:35 +0200 Subject: [PATCH] doc: clarify why we don't use SO_REUSEADDR for TCP on Windows --- src/win/tcp.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/win/tcp.c b/src/win/tcp.c index 27ad8dfd..61ae6e9a 100644 --- a/src/win/tcp.c +++ b/src/win/tcp.c @@ -235,6 +235,17 @@ void uv_tcp_endgame(uv_loop_t* loop, uv_tcp_t* handle) { } +/* Unlike on Unix, here we don't set SO_REUSEADDR, because it doesn't just + * allow binding to addresses that are in use by sockets in TIME_WAIT, it + * effectively allows 'stealing' a port which is in use by another application. + * + * SO_EXCLUSIVEADDRUSE is also not good here because it does cehck all sockets, + * regardless of state, so we'd get an error even if the port is in use by a + * socket in TIME_WAIT state. + * + * See issue #1360. + * + */ static int uv_tcp_try_bind(uv_tcp_t* handle, const struct sockaddr* addr, unsigned int addrlen,