SF#3563627: Set IP address on multicast socket from socket family
This commit is contained in:
Родитель
2a6c041422
Коммит
f6e6dbc0b7
|
@ -71,6 +71,7 @@ POCO_DECLARE_EXCEPTION(Net_API, POP3Exception, NetException)
|
|||
POCO_DECLARE_EXCEPTION(Net_API, ICMPException, NetException)
|
||||
POCO_DECLARE_EXCEPTION(Net_API, HTMLFormException, NetException)
|
||||
POCO_DECLARE_EXCEPTION(Net_API, WebSocketException, NetException)
|
||||
POCO_DECLARE_EXCEPTION(Net_API, UnsupportedFamilyException, NetException)
|
||||
|
||||
|
||||
} } // namespace Poco::Net
|
||||
|
|
|
@ -97,16 +97,18 @@ MulticastSocket& MulticastSocket::operator = (const Socket& socket)
|
|||
|
||||
void MulticastSocket::setInterface(const NetworkInterface& interfc)
|
||||
{
|
||||
if (!interfc.supportsIPv6())
|
||||
if (address().family() == IPAddress::IPv4)
|
||||
{
|
||||
impl()->setOption(IPPROTO_IP, IP_MULTICAST_IF, interfc.firstAddress(IPAddress::IPv4));
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(POCO_HAVE_IPv6)
|
||||
else if (address().family() == IPAddress::IPv6)
|
||||
{
|
||||
impl()->setOption(IPPROTO_IPV6, IPV6_MULTICAST_IF, interfc.index());
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
else
|
||||
throw UnsupportedFamilyException("Unknown or unsupported socket family.");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -68,6 +68,7 @@ POCO_IMPLEMENT_EXCEPTION(POP3Exception, NetException, "POP3 Exception")
|
|||
POCO_IMPLEMENT_EXCEPTION(ICMPException, NetException, "ICMP Exception")
|
||||
POCO_IMPLEMENT_EXCEPTION(HTMLFormException, NetException, "HTML Form Exception")
|
||||
POCO_IMPLEMENT_EXCEPTION(WebSocketException, NetException, "WebSocket Exception")
|
||||
POCO_IMPLEMENT_EXCEPTION(UnsupportedFamilyException, NetException, "Unknown or unsupported socket family.")
|
||||
|
||||
|
||||
} } // namespace Poco::Net
|
||||
|
|
Загрузка…
Ссылка в новой задаче