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_LINUX) | 8 #if defined(HOST_OS_LINUX) |
9 | 9 |
10 #include "bin/socket.h" | 10 #include "bin/socket.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 } | 39 } |
40 | 40 |
41 | 41 |
42 bool Socket::FormatNumericAddress(const RawAddr& addr, char* address, int len) { | 42 bool Socket::FormatNumericAddress(const RawAddr& addr, char* address, int len) { |
43 socklen_t salen = SocketAddress::GetAddrLength(addr); | 43 socklen_t salen = SocketAddress::GetAddrLength(addr); |
44 return (NO_RETRY_EXPECTED(getnameinfo(&addr.addr, salen, address, len, NULL, | 44 return (NO_RETRY_EXPECTED(getnameinfo(&addr.addr, salen, address, len, NULL, |
45 0, NI_NUMERICHOST) == 0)); | 45 0, NI_NUMERICHOST) == 0)); |
46 } | 46 } |
47 | 47 |
48 | 48 |
| 49 Socket::Socket(intptr_t fd) |
| 50 : ReferenceCounted(), fd_(fd), port_(ILLEGAL_PORT) {} |
| 51 |
| 52 |
| 53 void Socket::SetClosedFd() { |
| 54 fd_ = kClosedFd; |
| 55 } |
| 56 |
| 57 |
49 bool Socket::Initialize() { | 58 bool Socket::Initialize() { |
50 // Nothing to do on Linux. | 59 // Nothing to do on Linux. |
51 return true; | 60 return true; |
52 } | 61 } |
53 | 62 |
54 | 63 |
55 static intptr_t Create(const RawAddr& addr) { | 64 static intptr_t Create(const RawAddr& addr) { |
56 intptr_t fd; | 65 intptr_t fd; |
57 fd = NO_RETRY_EXPECTED( | 66 fd = NO_RETRY_EXPECTED( |
58 socket(addr.ss.ss_family, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0)); | 67 socket(addr.ss.ss_family, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0)); |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 return NO_RETRY_EXPECTED(setsockopt(fd, proto, MCAST_LEAVE_GROUP, &mreq, | 604 return NO_RETRY_EXPECTED(setsockopt(fd, proto, MCAST_LEAVE_GROUP, &mreq, |
596 sizeof(mreq))) == 0; | 605 sizeof(mreq))) == 0; |
597 } | 606 } |
598 | 607 |
599 } // namespace bin | 608 } // namespace bin |
600 } // namespace dart | 609 } // namespace dart |
601 | 610 |
602 #endif // defined(HOST_OS_LINUX) | 611 #endif // defined(HOST_OS_LINUX) |
603 | 612 |
604 #endif // !defined(DART_IO_DISABLED) | 613 #endif // !defined(DART_IO_DISABLED) |
OLD | NEW |