| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/globals.h" | 5 #include "platform/globals.h" |
| 6 #if defined(TARGET_OS_WINDOWS) | 6 #if defined(TARGET_OS_WINDOWS) |
| 7 | 7 |
| 8 #include "bin/builtin.h" | 8 #include "bin/builtin.h" |
| 9 #include "bin/eventhandler.h" | 9 #include "bin/eventhandler.h" |
| 10 #include "bin/file.h" | 10 #include "bin/file.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 host, | 103 host, |
| 104 &len); | 104 &len); |
| 105 if (err != 0) { | 105 if (err != 0) { |
| 106 Log::PrintErr("Error WSAAddressToString: %d\n", WSAGetLastError()); | 106 Log::PrintErr("Error WSAAddressToString: %d\n", WSAGetLastError()); |
| 107 return false; | 107 return false; |
| 108 } | 108 } |
| 109 return true; | 109 return true; |
| 110 } | 110 } |
| 111 | 111 |
| 112 intptr_t Socket::CreateConnect(RawAddr addr, const intptr_t port) { | 112 intptr_t Socket::CreateConnect(RawAddr addr, const intptr_t port) { |
| 113 SOCKET s = socket(addr.ss_family, SOCK_STREAM, 0); | 113 SOCKET s = socket(addr.ss.ss_family, SOCK_STREAM, 0); |
| 114 if (s == INVALID_SOCKET) { | 114 if (s == INVALID_SOCKET) { |
| 115 return -1; | 115 return -1; |
| 116 } | 116 } |
| 117 | 117 |
| 118 linger l; | 118 linger l; |
| 119 l.l_onoff = 1; | 119 l.l_onoff = 1; |
| 120 l.l_linger = 10; | 120 l.l_linger = 10; |
| 121 int status = setsockopt(s, | 121 int status = setsockopt(s, |
| 122 SOL_SOCKET, | 122 SOL_SOCKET, |
| 123 SO_LINGER, | 123 SO_LINGER, |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 } | 230 } |
| 231 } | 231 } |
| 232 freeaddrinfo(info); | 232 freeaddrinfo(info); |
| 233 return addresses; | 233 return addresses; |
| 234 } | 234 } |
| 235 | 235 |
| 236 | 236 |
| 237 intptr_t ServerSocket::CreateBindListen(RawAddr addr, | 237 intptr_t ServerSocket::CreateBindListen(RawAddr addr, |
| 238 intptr_t port, | 238 intptr_t port, |
| 239 intptr_t backlog) { | 239 intptr_t backlog) { |
| 240 SOCKET s = socket(addr.ss_family, SOCK_STREAM, IPPROTO_TCP); | 240 SOCKET s = socket(addr.ss.ss_family, SOCK_STREAM, IPPROTO_TCP); |
| 241 if (s == INVALID_SOCKET) { | 241 if (s == INVALID_SOCKET) { |
| 242 return -1; | 242 return -1; |
| 243 } | 243 } |
| 244 | 244 |
| 245 BOOL optval = true; | 245 BOOL optval = true; |
| 246 int status = setsockopt(s, | 246 int status = setsockopt(s, |
| 247 SOL_SOCKET, | 247 SOL_SOCKET, |
| 248 SO_REUSEADDR, | 248 SO_REUSEADDR, |
| 249 reinterpret_cast<const char*>(&optval), | 249 reinterpret_cast<const char*>(&optval), |
| 250 sizeof(optval)); | 250 sizeof(optval)); |
| 251 if (status == SOCKET_ERROR) { | 251 if (status == SOCKET_ERROR) { |
| 252 DWORD rc = WSAGetLastError(); | 252 DWORD rc = WSAGetLastError(); |
| 253 closesocket(s); | 253 closesocket(s); |
| 254 SetLastError(rc); | 254 SetLastError(rc); |
| 255 return -1; | 255 return -1; |
| 256 } | 256 } |
| 257 | 257 |
| 258 if (addr.ss_family == AF_INET6) { | 258 if (addr.ss.ss_family == AF_INET6) { |
| 259 optval = false; | 259 optval = false; |
| 260 setsockopt(s, | 260 setsockopt(s, |
| 261 IPPROTO_IPV6, | 261 IPPROTO_IPV6, |
| 262 IPV6_V6ONLY, | 262 IPV6_V6ONLY, |
| 263 reinterpret_cast<const char*>(&optval), | 263 reinterpret_cast<const char*>(&optval), |
| 264 sizeof(optval)); | 264 sizeof(optval)); |
| 265 } | 265 } |
| 266 | 266 |
| 267 SocketAddress::SetAddrPort(&addr, port); | 267 SocketAddress::SetAddrPort(&addr, port); |
| 268 status = bind(s, | 268 status = bind(s, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 SocketHandle* handle = reinterpret_cast<SocketHandle*>(fd); | 320 SocketHandle* handle = reinterpret_cast<SocketHandle*>(fd); |
| 321 int on = enabled ? 1 : 0; | 321 int on = enabled ? 1 : 0; |
| 322 return setsockopt(fd, | 322 return setsockopt(fd, |
| 323 IPPROTO_TCP, | 323 IPPROTO_TCP, |
| 324 TCP_NODELAY, | 324 TCP_NODELAY, |
| 325 reinterpret_cast<char *>(&on), | 325 reinterpret_cast<char *>(&on), |
| 326 sizeof(on)) == 0; | 326 sizeof(on)) == 0; |
| 327 } | 327 } |
| 328 | 328 |
| 329 #endif // defined(TARGET_OS_WINDOWS) | 329 #endif // defined(TARGET_OS_WINDOWS) |
| OLD | NEW |