Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
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 56a8101
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
3 changes: 1 addition & 2 deletions deps/uv/src/win/tcp.c
Expand Up @@ -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;
Expand Down
7 changes: 3 additions & 4 deletions deps/uv/src/win/udp.c
Expand Up @@ -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) {
Expand All @@ -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;
Expand All @@ -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,
Expand Down

0 comments on commit 56a8101

Please sign in to comment.