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_LINUX) | 8 #if defined(TARGET_OS_LINUX) |
9 | 9 |
10 #include "bin/socket.h" | 10 #include "bin/socket.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 bind(fd, &source_addr.addr, SocketAddress::GetAddrLength(source_addr))); | 94 bind(fd, &source_addr.addr, SocketAddress::GetAddrLength(source_addr))); |
95 if ((result != 0) && (errno != EINPROGRESS)) { | 95 if ((result != 0) && (errno != EINPROGRESS)) { |
96 VOID_TEMP_FAILURE_RETRY(close(fd)); | 96 VOID_TEMP_FAILURE_RETRY(close(fd)); |
97 return -1; | 97 return -1; |
98 } | 98 } |
99 | 99 |
100 return Connect(fd, addr); | 100 return Connect(fd, addr); |
101 } | 101 } |
102 | 102 |
103 | 103 |
| 104 bool Socket::IsBindError(intptr_t error_number) { |
| 105 return error_number == EADDRINUSE || error_number == EADDRNOTAVAIL || |
| 106 error_number == EINVAL; |
| 107 } |
| 108 |
| 109 |
104 intptr_t Socket::Available(intptr_t fd) { | 110 intptr_t Socket::Available(intptr_t fd) { |
105 return FDUtils::AvailableBytes(fd); | 111 return FDUtils::AvailableBytes(fd); |
106 } | 112 } |
107 | 113 |
108 | 114 |
109 intptr_t Socket::Read(intptr_t fd, void* buffer, intptr_t num_bytes) { | 115 intptr_t Socket::Read(intptr_t fd, void* buffer, intptr_t num_bytes) { |
110 ASSERT(fd >= 0); | 116 ASSERT(fd >= 0); |
111 ssize_t read_bytes = TEMP_FAILURE_RETRY(read(fd, buffer, num_bytes)); | 117 ssize_t read_bytes = TEMP_FAILURE_RETRY(read(fd, buffer, num_bytes)); |
112 ASSERT(EAGAIN == EWOULDBLOCK); | 118 ASSERT(EAGAIN == EWOULDBLOCK); |
113 if ((read_bytes == -1) && (errno == EWOULDBLOCK)) { | 119 if ((read_bytes == -1) && (errno == EWOULDBLOCK)) { |
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 return NO_RETRY_EXPECTED( | 593 return NO_RETRY_EXPECTED( |
588 setsockopt(fd, proto, MCAST_LEAVE_GROUP, &mreq, sizeof(mreq))) == 0; | 594 setsockopt(fd, proto, MCAST_LEAVE_GROUP, &mreq, sizeof(mreq))) == 0; |
589 } | 595 } |
590 | 596 |
591 } // namespace bin | 597 } // namespace bin |
592 } // namespace dart | 598 } // namespace dart |
593 | 599 |
594 #endif // defined(TARGET_OS_LINUX) | 600 #endif // defined(TARGET_OS_LINUX) |
595 | 601 |
596 #endif // !defined(DART_IO_DISABLED) | 602 #endif // !defined(DART_IO_DISABLED) |
OLD | NEW |