Chromium Code Reviews| 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 #if !defined(DART_IO_DISABLED) | 5 #if !defined(DART_IO_DISABLED) |
| 6 | 6 |
| 7 #include "platform/globals.h" | 7 #include "platform/globals.h" |
| 8 #if defined(HOST_OS_WINDOWS) | 8 #if defined(HOST_OS_WINDOWS) |
| 9 | 9 |
| 10 #include "bin/builtin.h" | 10 #include "bin/builtin.h" |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 41 SOCKET s = socket(addr.ss.ss_family, SOCK_STREAM, 0); | 41 SOCKET s = socket(addr.ss.ss_family, SOCK_STREAM, 0); |
| 42 if (s == INVALID_SOCKET) { | 42 if (s == INVALID_SOCKET) { |
| 43 return -1; | 43 return -1; |
| 44 } | 44 } |
| 45 | 45 |
| 46 linger l; | 46 linger l; |
| 47 l.l_onoff = 1; | 47 l.l_onoff = 1; |
| 48 l.l_linger = 10; | 48 l.l_linger = 10; |
| 49 int status = setsockopt(s, SOL_SOCKET, SO_LINGER, reinterpret_cast<char*>(&l), | 49 int status = setsockopt(s, SOL_SOCKET, SO_LINGER, reinterpret_cast<char*>(&l), |
| 50 sizeof(l)); | 50 sizeof(l)); |
| 51 if (status != NO_ERROR) { | 51 if (status != MX_OK) { |
|
zra
2017/06/09 19:24:25
ditto
| |
| 52 FATAL("Failed setting SO_LINGER on socket"); | 52 FATAL("Failed setting SO_LINGER on socket"); |
| 53 } | 53 } |
| 54 | 54 |
| 55 ClientSocket* client_socket = new ClientSocket(s); | 55 ClientSocket* client_socket = new ClientSocket(s); |
| 56 return reinterpret_cast<intptr_t>(client_socket); | 56 return reinterpret_cast<intptr_t>(client_socket); |
| 57 } | 57 } |
| 58 | 58 |
| 59 | 59 |
| 60 static intptr_t Connect(intptr_t fd, | 60 static intptr_t Connect(intptr_t fd, |
| 61 const RawAddr& addr, | 61 const RawAddr& addr, |
| 62 const RawAddr& bind_addr) { | 62 const RawAddr& bind_addr) { |
| 63 ASSERT(reinterpret_cast<Handle*>(fd)->is_client_socket()); | 63 ASSERT(reinterpret_cast<Handle*>(fd)->is_client_socket()); |
| 64 ClientSocket* handle = reinterpret_cast<ClientSocket*>(fd); | 64 ClientSocket* handle = reinterpret_cast<ClientSocket*>(fd); |
| 65 SOCKET s = handle->socket(); | 65 SOCKET s = handle->socket(); |
| 66 | 66 |
| 67 int status = | 67 int status = |
| 68 bind(s, &bind_addr.addr, SocketAddress::GetAddrLength(bind_addr)); | 68 bind(s, &bind_addr.addr, SocketAddress::GetAddrLength(bind_addr)); |
| 69 if (status != NO_ERROR) { | 69 if (status != MX_OK) { |
| 70 int rc = WSAGetLastError(); | 70 int rc = WSAGetLastError(); |
| 71 handle->mark_closed(); // Destructor asserts that socket is marked closed. | 71 handle->mark_closed(); // Destructor asserts that socket is marked closed. |
| 72 handle->Release(); | 72 handle->Release(); |
| 73 closesocket(s); | 73 closesocket(s); |
| 74 SetLastError(rc); | 74 SetLastError(rc); |
| 75 return -1; | 75 return -1; |
| 76 } | 76 } |
| 77 | 77 |
| 78 LPFN_CONNECTEX connectEx = NULL; | 78 LPFN_CONNECTEX connectEx = NULL; |
| 79 GUID guid_connect_ex = WSAID_CONNECTEX; | 79 GUID guid_connect_ex = WSAID_CONNECTEX; |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 266 } | 266 } |
| 267 return true; | 267 return true; |
| 268 } | 268 } |
| 269 | 269 |
| 270 } // namespace bin | 270 } // namespace bin |
| 271 } // namespace dart | 271 } // namespace dart |
| 272 | 272 |
| 273 #endif // defined(HOST_OS_WINDOWS) | 273 #endif // defined(HOST_OS_WINDOWS) |
| 274 | 274 |
| 275 #endif // !defined(DART_IO_DISABLED) | 275 #endif // !defined(DART_IO_DISABLED) |
| OLD | NEW |