Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Windows: don't report ENOTSOCK when attempting to bind an udp handle …

…twice
  • Loading branch information...
piscisaureus committed Apr 5, 2012
1 parent 3e88572 commit 56a81011927940f03899a770c6ae4b50ce958cf9
Showing with 4 additions and 6 deletions.
  1. +1 −2 deps/uv/src/win/tcp.c
  2. +3 −4 deps/uv/src/win/udp.c
@@ -252,10 +252,9 @@ static int uv__bind(uv_tcp_t* handle,
int addrsize) {
DWORD err;
int r;
SOCKET sock;

if (handle->socket == INVALID_SOCKET) {
sock = socket(domain, SOCK_STREAM, 0);
SOCKET sock = socket(domain, SOCK_STREAM, 0);
if (sock == INVALID_SOCKET) {
uv__set_sys_error(handle->loop, WSAGetLastError());
return -1;
@@ -163,7 +163,6 @@ static int uv__bind(uv_udp_t* handle,
int addrsize,
unsigned int flags) {
int r;
SOCKET sock;
DWORD no = 0, yes = 1;

if ((flags & UV_UDP_IPV6ONLY) && domain != AF_INET6) {
@@ -173,7 +172,7 @@ static int uv__bind(uv_udp_t* handle,
}

if (handle->socket == INVALID_SOCKET) {
sock = socket(domain, SOCK_DGRAM, 0);
SOCKET sock = socket(domain, SOCK_DGRAM, 0);
if (sock == INVALID_SOCKET) {
uv__set_sys_error(handle->loop, WSAGetLastError());
return -1;
@@ -192,14 +191,14 @@ static int uv__bind(uv_udp_t* handle,
/* TODO: how to handle errors? This may fail if there is no ipv4 stack */
/* available, or when run on XP/2003 which have no support for dualstack */
/* sockets. For now we're silently ignoring the error. */
setsockopt(sock,
setsockopt(handle->socket,
IPPROTO_IPV6,
IPV6_V6ONLY,
(char*) &no,
sizeof no);
}

r = setsockopt(sock,
r = setsockopt(handle->socket,
SOL_SOCKET,
SO_REUSEADDR,
(char*) &yes,

0 comments on commit 56a8101

Please sign in to comment.
You can’t perform that action at this time.