mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-12 10:13:51 +01:00
Fix multicast leave group (#3929)
* Fix multicast leave group * Add test to join and leave a multicast group Co-authored-by: Denis CLAVIER <denis.clavier@c-s.fr>
This commit is contained in:
parent
ac0c62ebf4
commit
d4e2e00482
@ -257,8 +257,7 @@ NetworkInterface MulticastSocket::findFirstInterface(const IPAddress& groupAddre
|
||||
|
||||
void MulticastSocket::leaveGroup(const IPAddress& groupAddress)
|
||||
{
|
||||
NetworkInterface intf;
|
||||
leaveGroup(groupAddress, intf);
|
||||
leaveGroup(groupAddress, findFirstInterface(groupAddress));
|
||||
}
|
||||
|
||||
|
||||
|
@ -51,6 +51,8 @@ void MulticastSocketTest::testMulticast()
|
||||
{
|
||||
MulticastEchoServer echoServer;
|
||||
MulticastSocket ms(SocketAddress::IPv4);
|
||||
SocketAddress multicastAddress("234.2.2.2", 4040);
|
||||
ms.joinGroup(multicastAddress.host());
|
||||
ms.setReceiveTimeout(Poco::Timespan(5, 0));
|
||||
int n = ms.sendTo("hello", 5, echoServer.group());
|
||||
assertTrue (n == 5);
|
||||
@ -58,6 +60,7 @@ void MulticastSocketTest::testMulticast()
|
||||
n = ms.receiveBytes(buffer, sizeof(buffer));
|
||||
assertTrue (n == 5);
|
||||
assertTrue (std::string(buffer, n) == "hello");
|
||||
ms.leaveGroup(multicastAddress.host());
|
||||
ms.close();
|
||||
}
|
||||
catch (Poco::NotImplementedException&)
|
||||
|
Loading…
Reference in New Issue
Block a user