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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 ListenSocket* listen_socket = new ListenSocket(s); | 281 ListenSocket* listen_socket = new ListenSocket(s); |
282 return reinterpret_cast<intptr_t>(listen_socket); | 282 return reinterpret_cast<intptr_t>(listen_socket); |
283 } | 283 } |
284 | 284 |
285 | 285 |
286 void Socket::Close(intptr_t fd) { | 286 void Socket::Close(intptr_t fd) { |
287 ClientSocket* client_socket = reinterpret_cast<ClientSocket*>(fd); | 287 ClientSocket* client_socket = reinterpret_cast<ClientSocket*>(fd); |
288 client_socket->Close(); | 288 client_socket->Close(); |
289 } | 289 } |
290 | 290 |
| 291 |
| 292 static bool SetBlockingHelper(intptr_t fd, bool blocking) { |
| 293 SocketHandle* handle = reinterpret_cast<SocketHandle*>(fd); |
| 294 u_long iMode = blocking ? 0 : 1; |
| 295 int status = ioctlsocket(handle->socket(), FIONBIO, &iMode); |
| 296 if (status != NO_ERROR) { |
| 297 Log::PrintErr("ioctlsocket FIONBIO failed: %d\n", status); |
| 298 return false; |
| 299 } |
| 300 return true; |
| 301 } |
| 302 |
| 303 |
| 304 bool Socket::SetNonBlocking(intptr_t fd) { |
| 305 return SetBlockingHelper(fd, false); |
| 306 } |
| 307 |
| 308 |
| 309 bool Socket::SetBlocking(intptr_t fd) { |
| 310 return SetBlockingHelper(fd, true); |
| 311 } |
| 312 |
291 #endif // defined(TARGET_OS_WINDOWS) | 313 #endif // defined(TARGET_OS_WINDOWS) |
OLD | NEW |