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(TARGET_OS_MACOS) | 8 #if defined(TARGET_OS_MACOS) |
9 | 9 |
10 #include "bin/socket.h" | 10 #include "bin/socket.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 bind(fd, &source_addr.addr, SocketAddress::GetAddrLength(source_addr))); | 96 bind(fd, &source_addr.addr, SocketAddress::GetAddrLength(source_addr))); |
97 if ((result != 0) && (errno != EINPROGRESS)) { | 97 if ((result != 0) && (errno != EINPROGRESS)) { |
98 VOID_TEMP_FAILURE_RETRY(close(fd)); | 98 VOID_TEMP_FAILURE_RETRY(close(fd)); |
99 return -1; | 99 return -1; |
100 } | 100 } |
101 | 101 |
102 return Connect(fd, addr); | 102 return Connect(fd, addr); |
103 } | 103 } |
104 | 104 |
105 | 105 |
| 106 bool Socket::IsBindError(intptr_t error_number) { |
| 107 return error_number == EADDRINUSE || error_number == EADDRNOTAVAIL || |
| 108 error_number == EINVAL; |
| 109 } |
| 110 |
| 111 |
106 intptr_t Socket::Available(intptr_t fd) { | 112 intptr_t Socket::Available(intptr_t fd) { |
107 return FDUtils::AvailableBytes(fd); | 113 return FDUtils::AvailableBytes(fd); |
108 } | 114 } |
109 | 115 |
110 | 116 |
111 intptr_t Socket::Read(intptr_t fd, void* buffer, intptr_t num_bytes) { | 117 intptr_t Socket::Read(intptr_t fd, void* buffer, intptr_t num_bytes) { |
112 ASSERT(fd >= 0); | 118 ASSERT(fd >= 0); |
113 ssize_t read_bytes = TEMP_FAILURE_RETRY(read(fd, buffer, num_bytes)); | 119 ssize_t read_bytes = TEMP_FAILURE_RETRY(read(fd, buffer, num_bytes)); |
114 ASSERT(EAGAIN == EWOULDBLOCK); | 120 ASSERT(EAGAIN == EWOULDBLOCK); |
115 if ((read_bytes == -1) && (errno == EWOULDBLOCK)) { | 121 if ((read_bytes == -1) && (errno == EWOULDBLOCK)) { |
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 int interfaceIndex) { | 631 int interfaceIndex) { |
626 return JoinOrLeaveMulticast(fd, addr, interface, interfaceIndex, false); | 632 return JoinOrLeaveMulticast(fd, addr, interface, interfaceIndex, false); |
627 } | 633 } |
628 | 634 |
629 } // namespace bin | 635 } // namespace bin |
630 } // namespace dart | 636 } // namespace dart |
631 | 637 |
632 #endif // defined(TARGET_OS_MACOS) | 638 #endif // defined(TARGET_OS_MACOS) |
633 | 639 |
634 #endif // !defined(DART_IO_DISABLED) | 640 #endif // !defined(DART_IO_DISABLED) |
OLD | NEW |