OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef NET_BASE_IP_ENDPOINT_H_ | 5 #ifndef NET_BASE_IP_ENDPOINT_H_ |
6 #define NET_BASE_IP_ENDPOINT_H_ | 6 #define NET_BASE_IP_ENDPOINT_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 bool ToSockAddr(struct sockaddr* address, socklen_t* address_length) const | 46 bool ToSockAddr(struct sockaddr* address, socklen_t* address_length) const |
47 WARN_UNUSED_RESULT; | 47 WARN_UNUSED_RESULT; |
48 | 48 |
49 // Convert from a sockaddr struct. | 49 // Convert from a sockaddr struct. |
50 // |address| is the address. | 50 // |address| is the address. |
51 // |address_length| is the length of |address|. | 51 // |address_length| is the length of |address|. |
52 // Returns true on success, false on failure. | 52 // Returns true on success, false on failure. |
53 bool FromSockAddr(const struct sockaddr* address, socklen_t address_length) | 53 bool FromSockAddr(const struct sockaddr* address, socklen_t address_length) |
54 WARN_UNUSED_RESULT; | 54 WARN_UNUSED_RESULT; |
55 | 55 |
56 // Returns value as a string (e.g. "127.0.0.1:80"). Returns empty | 56 // Returns value as a string (e.g. "127.0.0.1:80"). The IP address must be |
57 // string if the address is invalid, and cannot not be converted to a | 57 // valid. |
58 // string. | |
59 std::string ToString() const; | 58 std::string ToString() const; |
60 | 59 |
61 // As above, but without port. | 60 // As above, but without port. |
62 std::string ToStringWithoutPort() const; | 61 std::string ToStringWithoutPort() const; |
63 | 62 |
64 bool operator<(const IPEndPoint& that) const; | 63 bool operator<(const IPEndPoint& that) const; |
65 bool operator==(const IPEndPoint& that) const; | 64 bool operator==(const IPEndPoint& that) const; |
66 | 65 |
67 private: | 66 private: |
68 IPAddressNumber address_; | 67 IPAddressNumber address_; |
69 uint16 port_; | 68 uint16 port_; |
70 }; | 69 }; |
71 | 70 |
72 } // namespace net | 71 } // namespace net |
73 | 72 |
74 #endif // NET_BASE_IP_ENDPOINT_H_ | 73 #endif // NET_BASE_IP_ENDPOINT_H_ |
OLD | NEW |