| 116 | } |
| 117 | |
| 118 | std::string InetAddress::ToString() const |
| 119 | { |
| 120 | std::string result; |
| 121 | result.reserve( std::strlen( "255.255.255.255:65535") ); |
| 122 | |
| 123 | in_addr ip; |
| 124 | #ifdef _WIN32 |
| 125 | ip.S_un.S_addr= ::htonl( ip_address ); |
| 126 | #else |
| 127 | ip.s_addr= htonl( ip_address ); |
| 128 | #endif |
| 129 | |
| 130 | result+= ::inet_ntoa( ip ); |
| 131 | result+= ":" + std::to_string( port ); |
| 132 | |
| 133 | return result; |
| 134 | } |
| 135 | |
| 136 | class NetConnection final : public IConnection |
| 137 | { |