21 Internet protocol [internet]

21.13 Class template ip::basic_endpoint [internet.endpoint]

21.13.4 ip::basic_endpoint I/O [internet.endpoint.io]

template<class CharT, class Traits, class InternetProtocol> basic_ostream<CharT, Traits>& operator<<( basic_ostream<CharT, Traits>& os, const basic_endpoint<InternetProtocol>& ep);

Effects: Outputs a representation of the endpoint to the stream, as if it were implemented as follows:

basic_ostringstream<CharT, Traits> ss;
if (ep.protocol() == basic_endpoint<InternetProtocol>::protocol_type::v6())
  ss << "[" << ep.address() << "]";
  ss << ep.address();
ss << ":" << ep.port();
os << ss.str();

Returns: os.

Note: The representation of the endpoint when it contains an IP version 6 address is based on [RFC2732].  — end note ]