Dear Lukas,
Experimenting with multicast, I found it convenient to be able to set
the interface for multicast traffic. My suggestion allows setting this
interface. It might be handy to have a overloaded version or to use two
different procedures. It let this up to you to decide whatever is better
for compatibility with other platforms.
Also I did not yet cover the IP6 part.
---
procedure TUDPBlockSocket.AddMulticast(MCastIP, MCastInAddr: string);
var
Multicast: TIP_mreq;
Multicast6: TIPv6_mreq;
n: integer;
ip6: Tip6bytes;
begin
if FIP6Used then
begin
ip6 := StrToIp6(MCastIP);
for n := 0 to 15 do
Multicast6.ipv6mr_multiaddr.u6_addr8[n] := Ip6[n];
Multicast6.ipv6mr_interface := 0;
SockCheck(synsock.SetSockOpt(FSocket, IPPROTO_IPV6, IPV6_JOIN_GROUP,
PAnsiChar(@Multicast6), SizeOf(Multicast6)));
end
else
begin
if MCastInAddr='' then
MCastInAddr := cAnyHost;
Multicast.imr_multiaddr.S_addr := swapbytes(strtoip(MCastIP));
Multicast.imr_interface.S_addr := swapbytes(strtoip(MCastInAddr));
SockCheck(synsock.SetSockOpt(FSocket, IPPROTO_IP, IP_ADD_MEMBERSHIP,
PAnsiChar(@Multicast), SizeOf(Multicast)));
end;
ExceptCheck;
end;
---
Best regards
Thomas Kerkmann
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
synalist-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/synalist-public