Chromium Code Reviews| Index: net/base/ip_endpoint.cc |
| diff --git a/net/base/ip_endpoint.cc b/net/base/ip_endpoint.cc |
| index 626d12e9895a14207b23a1aac9f57411ce69e66b..df90f1a0eb8b23ed35a977d8fa2229ea33f17559 100644 |
| --- a/net/base/ip_endpoint.cc |
| +++ b/net/base/ip_endpoint.cc |
| @@ -5,6 +5,7 @@ |
| #include "net/base/ip_endpoint.h" |
| #include "base/logging.h" |
| +#include "base/string_number_conversions.h" |
| #if defined(OS_WIN) |
| #include <winsock2.h> |
| #elif defined(OS_POSIX) |
| @@ -108,6 +109,16 @@ bool IPEndPoint::FromSockAddr(const struct sockaddr* address, |
| return true; |
| } |
| +std::string IPEndPoint::ToString() const { |
| + struct sockaddr_storage addr_storage; |
| + size_t addr_len = sizeof(addr_storage); |
| + struct sockaddr* addr = reinterpret_cast<struct sockaddr*>(&addr_storage); |
| + if (!ToSockAddr(addr, &addr_len)) { |
| + return ""; |
| + } |
| + return NetAddressToString(addr, addr_len) + ":" + base::IntToString(port_); |
|
pmarks
2011/03/28 01:53:45
This looks like it will mangle IPv6 addresses. Us
|
| +} |
| + |
| bool IPEndPoint::operator<(const IPEndPoint& that) const { |
| return address_ < that.address_ || port_ < that.port_; |
| } |