OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "net/base/net_util.h" | 10 #include "net/base/net_util.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 // the address that was copied into |address|. | 37 // the address that was copied into |address|. |
38 // Returns true on success, false on failure. | 38 // Returns true on success, false on failure. |
39 bool ToSockAddr(struct sockaddr* address, size_t* address_length) const; | 39 bool ToSockAddr(struct sockaddr* address, size_t* address_length) const; |
40 | 40 |
41 // Convert from a sockaddr struct. | 41 // Convert from a sockaddr struct. |
42 // |address| is the address. | 42 // |address| is the address. |
43 // |address_length| is the length of |address|. | 43 // |address_length| is the length of |address|. |
44 // Returns true on success, false on failure. | 44 // Returns true on success, false on failure. |
45 bool FromSockAddr(const struct sockaddr* address, size_t address_length); | 45 bool FromSockAddr(const struct sockaddr* address, size_t address_length); |
46 | 46 |
| 47 // Returns value as a string (e.g. "127.0.0.1:80"). Returns empty |
| 48 // string if the address is invalid, and cannot not be converted to a |
| 49 // string. |
| 50 std::string ToString() const; |
| 51 |
47 bool operator<(const IPEndPoint& that) const; | 52 bool operator<(const IPEndPoint& that) const; |
48 bool operator==(const IPEndPoint& that) const; | 53 bool operator==(const IPEndPoint& that) const; |
49 | 54 |
50 private: | 55 private: |
51 IPAddressNumber address_; | 56 IPAddressNumber address_; |
52 int port_; | 57 int port_; |
53 }; | 58 }; |
54 | 59 |
55 } // namespace net | 60 } // namespace net |
56 | 61 |
57 #endif // NET_BASE_IP_ENDPOINT_H_ | 62 #endif // NET_BASE_IP_ENDPOINT_H_ |
OLD | NEW |