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 cda7a28 commit 3506cd1dc5e941acb216b2118cfc784b78fcc4f1
Showing with 4 additions and 6 deletions.
  1. +1 −2 src/win/tcp.c
  2. +3 −4 src/win/udp.c
@@ -239,10 +239,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;
@@ -167,7 +167,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) {
@@ -177,7 +176,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;
@@ -196,14 +195,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 3506cd1

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