clean build with POCO_NET_NO_IPv6, add test for Unix domain sockets

This commit is contained in:
Guenter Obiltschnig
2015-09-08 15:00:43 +02:00
parent d64ec94653
commit d55eab9264
9 changed files with 108 additions and 47 deletions

View File

@@ -35,7 +35,9 @@ using Poco::UInt16;
using Poco::UInt32;
using Poco::Net::Impl::IPAddressImpl;
using Poco::Net::Impl::IPv4AddressImpl;
#if defined(POCO_HAVE_IPv6)
using Poco::Net::Impl::IPv6AddressImpl;
#endif
namespace Poco {
@@ -58,8 +60,10 @@ IPAddress::IPAddress(const IPAddress& addr)
{
if (addr.family() == IPv4)
newIPv4(addr.addr());
#if defined(POCO_HAVE_IPv6)
else
newIPv6(addr.addr(), addr.scope());
#endif
}
@@ -71,8 +75,7 @@ IPAddress::IPAddress(Family family)
else if (family == IPv6)
newIPv6();
#endif
else
throw Poco::InvalidArgumentException("Invalid or unsupported address family passed to IPAddress()");
else throw Poco::InvalidArgumentException("Invalid or unsupported address family passed to IPAddress()");
}
@@ -227,8 +230,12 @@ IPAddress& IPAddress::operator = (const IPAddress& addr)
destruct();
if (addr.family() == IPAddress::IPv4)
newIPv4(addr.addr());
else
#if defined(POCO_HAVE_IPv6)
else if (addr.family() == IPAddress::IPv6)
newIPv6(addr.addr(), addr.scope());
#endif
else
throw Poco::InvalidArgumentException("Invalid or unsupported address family");
}
return *this;
}
@@ -236,7 +243,7 @@ IPAddress& IPAddress::operator = (const IPAddress& addr)
IPAddress::Family IPAddress::family() const
{
return static_cast<IPAddress::Family>(pImpl()->family());
return pImpl()->family();
}

View File

@@ -96,9 +96,13 @@ void ServerSocket::bind6(const SocketAddress& address, bool reuseAddress, bool i
void ServerSocket::bind6(Poco::UInt16 port, bool reuseAddress, bool ipV6Only)
{
#if defined(POCO_HAVE_IPv6)
IPAddress wildcardAddr(IPAddress::IPv6);
SocketAddress address(wildcardAddr, port);
impl()->bind6(address, reuseAddress, ipV6Only);
#else
throw Poco::NotImplementedException("No IPv6 support available");
#endif // POCO_HAVE_IPv6
}