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(HOST_OS_MACOS) | 8 #if defined(HOST_OS_MACOS) |
9 | 9 |
10 #include "bin/socket.h" | 10 #include "bin/socket.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 } | 38 } |
39 | 39 |
40 | 40 |
41 bool Socket::FormatNumericAddress(const RawAddr& addr, char* address, int len) { | 41 bool Socket::FormatNumericAddress(const RawAddr& addr, char* address, int len) { |
42 socklen_t salen = SocketAddress::GetAddrLength(addr); | 42 socklen_t salen = SocketAddress::GetAddrLength(addr); |
43 return (NO_RETRY_EXPECTED(getnameinfo(&addr.addr, salen, address, len, NULL, | 43 return (NO_RETRY_EXPECTED(getnameinfo(&addr.addr, salen, address, len, NULL, |
44 0, NI_NUMERICHOST)) == 0); | 44 0, NI_NUMERICHOST)) == 0); |
45 } | 45 } |
46 | 46 |
47 | 47 |
| 48 Socket::Socket(intptr_t fd) |
| 49 : ReferenceCounted(), fd_(fd), port_(ILLEGAL_PORT) {} |
| 50 |
| 51 |
| 52 void Socket::SetClosedFd() { |
| 53 fd_ = kClosedFd; |
| 54 } |
| 55 |
| 56 |
48 bool Socket::Initialize() { | 57 bool Socket::Initialize() { |
49 // Nothing to do on Mac OS. | 58 // Nothing to do on Mac OS. |
50 return true; | 59 return true; |
51 } | 60 } |
52 | 61 |
53 | 62 |
54 static intptr_t Create(const RawAddr& addr) { | 63 static intptr_t Create(const RawAddr& addr) { |
55 intptr_t fd; | 64 intptr_t fd; |
56 fd = NO_RETRY_EXPECTED(socket(addr.ss.ss_family, SOCK_STREAM, 0)); | 65 fd = NO_RETRY_EXPECTED(socket(addr.ss.ss_family, SOCK_STREAM, 0)); |
57 if (fd < 0) { | 66 if (fd < 0) { |
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 int interfaceIndex) { | 633 int interfaceIndex) { |
625 return JoinOrLeaveMulticast(fd, addr, interface, interfaceIndex, false); | 634 return JoinOrLeaveMulticast(fd, addr, interface, interfaceIndex, false); |
626 } | 635 } |
627 | 636 |
628 } // namespace bin | 637 } // namespace bin |
629 } // namespace dart | 638 } // namespace dart |
630 | 639 |
631 #endif // defined(HOST_OS_MACOS) | 640 #endif // defined(HOST_OS_MACOS) |
632 | 641 |
633 #endif // !defined(DART_IO_DISABLED) | 642 #endif // !defined(DART_IO_DISABLED) |
OLD | NEW |