| 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 #ifndef BIN_SOCKET_H_ | 5 #ifndef BIN_SOCKET_H_ |
| 6 #define BIN_SOCKET_H_ | 6 #define BIN_SOCKET_H_ |
| 7 | 7 |
| 8 #include "bin/builtin.h" | 8 #include "bin/builtin.h" |
| 9 #include "bin/utils.h" | 9 #include "bin/utils.h" |
| 10 #include "bin/dartutils.h" | 10 #include "bin/dartutils.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 | 45 |
| 46 enum { | 46 enum { |
| 47 ADDRESS_LOOPBACK_IP_V4, | 47 ADDRESS_LOOPBACK_IP_V4, |
| 48 ADDRESS_LOOPBACK_IP_V6, | 48 ADDRESS_LOOPBACK_IP_V6, |
| 49 ADDRESS_ANY_IP_V4, | 49 ADDRESS_ANY_IP_V4, |
| 50 ADDRESS_ANY_IP_V6, | 50 ADDRESS_ANY_IP_V6, |
| 51 ADDRESS_FIRST = ADDRESS_LOOPBACK_IP_V4, | 51 ADDRESS_FIRST = ADDRESS_LOOPBACK_IP_V4, |
| 52 ADDRESS_LAST = ADDRESS_ANY_IP_V6, | 52 ADDRESS_LAST = ADDRESS_ANY_IP_V6, |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 explicit SocketAddress(struct sockaddr* sockaddr); | 55 explicit SocketAddress(struct sockaddr* sa); |
| 56 | 56 |
| 57 ~SocketAddress() {} | 57 ~SocketAddress() {} |
| 58 | 58 |
| 59 int GetType() { | 59 int GetType() { |
| 60 if (addr_.ss.ss_family == AF_INET6) return TYPE_IPV6; | 60 if (addr_.ss.ss_family == AF_INET6) return TYPE_IPV6; |
| 61 return TYPE_IPV4; | 61 return TYPE_IPV4; |
| 62 } | 62 } |
| 63 | 63 |
| 64 const char* as_string() const { return as_string_; } | 64 const char* as_string() const { return as_string_; } |
| 65 const RawAddr& addr() const { return addr_; } | 65 const RawAddr& addr() const { return addr_; } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 94 | 94 |
| 95 private: | 95 private: |
| 96 char as_string_[INET6_ADDRSTRLEN]; | 96 char as_string_[INET6_ADDRSTRLEN]; |
| 97 RawAddr addr_; | 97 RawAddr addr_; |
| 98 | 98 |
| 99 DISALLOW_COPY_AND_ASSIGN(SocketAddress); | 99 DISALLOW_COPY_AND_ASSIGN(SocketAddress); |
| 100 }; | 100 }; |
| 101 | 101 |
| 102 class InterfaceSocketAddress { | 102 class InterfaceSocketAddress { |
| 103 public: | 103 public: |
| 104 explicit InterfaceSocketAddress(struct sockaddr* sockaddr, | 104 explicit InterfaceSocketAddress(struct sockaddr* sa, |
| 105 const char* interface_name) | 105 const char* interface_name) |
| 106 : socket_address_(new SocketAddress(sockaddr)), | 106 : socket_address_(new SocketAddress(sa)), |
| 107 interface_name_(interface_name) {} | 107 interface_name_(interface_name) {} |
| 108 | 108 |
| 109 ~InterfaceSocketAddress() { | 109 ~InterfaceSocketAddress() { |
| 110 delete socket_address_; | 110 delete socket_address_; |
| 111 free(const_cast<char*>(interface_name_)); | 111 free(const_cast<char*>(interface_name_)); |
| 112 } | 112 } |
| 113 | 113 |
| 114 SocketAddress* socket_address() const { return socket_address_; } | 114 SocketAddress* socket_address() const { return socket_address_; } |
| 115 const char* interface_name() const { return interface_name_; } | 115 const char* interface_name() const { return interface_name_; } |
| 116 | 116 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 | 224 |
| 225 private: | 225 private: |
| 226 DISALLOW_ALLOCATION(); | 226 DISALLOW_ALLOCATION(); |
| 227 DISALLOW_IMPLICIT_CONSTRUCTORS(ServerSocket); | 227 DISALLOW_IMPLICIT_CONSTRUCTORS(ServerSocket); |
| 228 }; | 228 }; |
| 229 | 229 |
| 230 } // namespace bin | 230 } // namespace bin |
| 231 } // namespace dart | 231 } // namespace dart |
| 232 | 232 |
| 233 #endif // BIN_SOCKET_H_ | 233 #endif // BIN_SOCKET_H_ |
| OLD | NEW |