OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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_ANDROID) | 8 #if defined(TARGET_OS_ANDROID) |
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 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 return NO_RETRY_EXPECTED(setsockopt( | 582 return NO_RETRY_EXPECTED(setsockopt( |
577 fd, proto, MCAST_LEAVE_GROUP, &mreq, sizeof(mreq))) == 0; | 583 fd, proto, MCAST_LEAVE_GROUP, &mreq, sizeof(mreq))) == 0; |
578 } | 584 } |
579 | 585 |
580 } // namespace bin | 586 } // namespace bin |
581 } // namespace dart | 587 } // namespace dart |
582 | 588 |
583 #endif // defined(TARGET_OS_ANDROID) | 589 #endif // defined(TARGET_OS_ANDROID) |
584 | 590 |
585 #endif // !defined(DART_IO_DISABLED) | 591 #endif // !defined(DART_IO_DISABLED) |
OLD | NEW |