| 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 | |
| 110 intptr_t Socket::Available(intptr_t fd) { | 104 intptr_t Socket::Available(intptr_t fd) { |
| 111 return FDUtils::AvailableBytes(fd); | 105 return FDUtils::AvailableBytes(fd); |
| 112 } | 106 } |
| 113 | 107 |
| 114 | 108 |
| 115 intptr_t Socket::Read(intptr_t fd, void* buffer, intptr_t num_bytes) { | 109 intptr_t Socket::Read(intptr_t fd, void* buffer, intptr_t num_bytes) { |
| 116 ASSERT(fd >= 0); | 110 ASSERT(fd >= 0); |
| 117 ssize_t read_bytes = TEMP_FAILURE_RETRY(read(fd, buffer, num_bytes)); | 111 ssize_t read_bytes = TEMP_FAILURE_RETRY(read(fd, buffer, num_bytes)); |
| 118 ASSERT(EAGAIN == EWOULDBLOCK); | 112 ASSERT(EAGAIN == EWOULDBLOCK); |
| 119 if ((read_bytes == -1) && (errno == EWOULDBLOCK)) { | 113 if ((read_bytes == -1) && (errno == EWOULDBLOCK)) { |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 return NO_RETRY_EXPECTED( | 587 return NO_RETRY_EXPECTED( |
| 594 setsockopt(fd, proto, MCAST_LEAVE_GROUP, &mreq, sizeof(mreq))) == 0; | 588 setsockopt(fd, proto, MCAST_LEAVE_GROUP, &mreq, sizeof(mreq))) == 0; |
| 595 } | 589 } |
| 596 | 590 |
| 597 } // namespace bin | 591 } // namespace bin |
| 598 } // namespace dart | 592 } // namespace dart |
| 599 | 593 |
| 600 #endif // defined(TARGET_OS_LINUX) | 594 #endif // defined(TARGET_OS_LINUX) |
| 601 | 595 |
| 602 #endif // !defined(DART_IO_DISABLED) | 596 #endif // !defined(DART_IO_DISABLED) |
| OLD | NEW |