Modify multicast socket initialization to allow datagram reception:

* perform the bind operation using 0.0.0.0

  * modify add_membership option to refers to the IP address of the
    actual interface used to transport the multicast traffic.
This commit is contained in:
Guillaume Foliard 2018-03-11 16:39:34 +01:00
parent 3bc31a9483
commit 9e0da0443c
1 changed files with 2 additions and 2 deletions

View File

@ -91,9 +91,9 @@ package body Sockets.Multicast is
Setsockopt (Result, SOL_SOCKET, SO_REUSEPORT, 1);
end if;
pragma Warnings (On);
Bind (Result, Local_Port, Host => Local_If);
Bind (Result, Local_Port);
Mreq.Imr_Multiaddr := To_In_Addr (Address_Of (Group));
Mreq.Imr_Interface := To_In_Addr (Address_Of ("0.0.0.0"));
Mreq.Imr_Interface := To_In_Addr (Address_Of (Local_If));
Setsockopt_Add_Membership (Result, Mreq);
Setsockopt (Result, IPPROTO_IP, IP_MULTICAST_TTL, TTL);
Setsockopt (Result, IPPROTO_IP, IP_MULTICAST_LOOP, C_Self_Loop);