bool IPAddress::operator<(const IPAddress& ha) const { if (AddressFamily != ha.AddressFamily) return (int)get_AddressFamily() < (int)ha.get_AddressFamily(); switch ((int)get_AddressFamily()) { case AF_INET: return memcmp(&m_sin.sin_addr, &ha.m_sin.sin_addr, 4) < 0; case AF_INET6: return memcmp(&m_sin6.sin6_addr, &ha.m_sin6.sin6_addr, 16) < 0; default: Throw(ExtErr::UnknownHostAddressType); } }
BinaryWriter& AFXAPI operator<<(BinaryWriter& wr, const IPAddress& ha) { wr << (short)ha.get_AddressFamily(); switch ((int)ha.get_AddressFamily()) { case AF_INET: wr.Write(&ha.m_sin.sin_addr, sizeof(ha.m_sin.sin_addr)); break; case AF_INET6: wr.Write(&ha.m_sin6.sin6_addr, sizeof(ha.m_sin6.sin6_addr)); break; default: wr.Write(&ha.m_sockaddr, sizeof(ha.m_sockaddr)); //!!! unknown size break; } return wr; }