예제 #1
0
bool IPAddress::operator < (const IPAddress& a) const
{
	poco_socklen_t l1 = length();
	poco_socklen_t l2 = a.length();
	if (l1 == l2)
    {
#if defined(POCO_HAVE_IPv6)
        if ( scope() != a.scope() )
            return scope() < a.scope();
#endif
		return std::memcmp(addr(), a.addr(), l1) < 0;
    }
	else return l1 < l2;
}
예제 #2
0
IPAddress::IPAddress(const IPAddress& addr)
{
	if (addr.family() == IPv4)
		newIPv4(addr.addr());
	else
		newIPv6(addr.addr(), addr.scope());
}
예제 #3
0
void SocketAddress::set(const IPAddress& host, UInt16 port) {
	if (host.family() == IPAddress::IPv6)
		_pAddress.reset(new IPv6SocketAddress(host, htons(port), host.scope()));
	else
		_pAddress.reset(new IPv4SocketAddress(host, htons(port)));
	_isNull = host.isWildcard() && port==0;
	_toString.clear();
}
예제 #4
0
void SocketAddress::init(const IPAddress& host, Poco::UInt16 port)
{
	if (host.family() == IPAddress::IPv4)
		_pImpl = new IPv4SocketAddressImpl(host.addr(), htons(port));
#if defined(POCO_HAVE_IPv6)
	else if (host.family() == IPAddress::IPv6)
		_pImpl = new IPv6SocketAddressImpl(host.addr(), htons(port), host.scope());
#endif
	else throw Poco::NotImplementedException("unsupported IP address family");
}
예제 #5
0
SocketAddress::SocketAddress(const IPAddress& host, UInt16 port) {
	if (host.family() == IPAddress::IPv6)
		_pAddress.reset(new IPv6SocketAddress(host, htons(port), host.scope()));
	else
		_pAddress.reset(new IPv4SocketAddress(host, htons(port)));
}