Skip to content

Commit f6e6dbc

Browse files
committed
SF#3563627: Set IP address on multicast socket from socket family
1 parent 2a6c041 commit f6e6dbc

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

Net/include/Poco/Net/NetException.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ POCO_DECLARE_EXCEPTION(Net_API, POP3Exception, NetException)
7171
POCO_DECLARE_EXCEPTION(Net_API, ICMPException, NetException)
7272
POCO_DECLARE_EXCEPTION(Net_API, HTMLFormException, NetException)
7373
POCO_DECLARE_EXCEPTION(Net_API, WebSocketException, NetException)
74+
POCO_DECLARE_EXCEPTION(Net_API, UnsupportedFamilyException, NetException)
7475

7576

7677
} } // namespace Poco::Net

Net/src/MulticastSocket.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,18 @@ MulticastSocket& MulticastSocket::operator = (const Socket& socket)
9797

9898
void MulticastSocket::setInterface(const NetworkInterface& interfc)
9999
{
100-
if (!interfc.supportsIPv6())
100+
if (address().family() == IPAddress::IPv4)
101101
{
102102
impl()->setOption(IPPROTO_IP, IP_MULTICAST_IF, interfc.firstAddress(IPAddress::IPv4));
103103
}
104-
else
105-
{
106104
#if defined(POCO_HAVE_IPv6)
105+
else if (address().family() == IPAddress::IPv6)
106+
{
107107
impl()->setOption(IPPROTO_IPV6, IPV6_MULTICAST_IF, interfc.index());
108-
#endif
109108
}
109+
#endif
110+
else
111+
throw UnsupportedFamilyException("Unknown or unsupported socket family.");
110112
}
111113

112114

Net/src/NetException.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ POCO_IMPLEMENT_EXCEPTION(POP3Exception, NetException, "POP3 Exception")
6868
POCO_IMPLEMENT_EXCEPTION(ICMPException, NetException, "ICMP Exception")
6969
POCO_IMPLEMENT_EXCEPTION(HTMLFormException, NetException, "HTML Form Exception")
7070
POCO_IMPLEMENT_EXCEPTION(WebSocketException, NetException, "WebSocket Exception")
71+
POCO_IMPLEMENT_EXCEPTION(UnsupportedFamilyException, NetException, "Unknown or unsupported socket family.")
7172

7273

7374
} } // namespace Poco::Net

0 commit comments

Comments
 (0)