开发者

Indy 10 and setting socket options

Maybe the solution to this is very simple and I'm just too dumb to see it. I need to recompile an old application with Indy 10 and t开发者_开发百科here's this line that used to be

inUDPServer.Binding.SetSockOpt(Id_IPPROTO_IP, Id_IP_ADD_MEMBERSHIP, PChar(@mreq), SizeOf(mreq));

but the new TIdSocketHandle.SetSockOpt takes 3 integers. Now how am I supposed to provide the ip_mreq? Just passing the imr_multiaddr.S_addr results in an #10014 Error - Buffer fault. Maybe one of you guys has an idea.

Cheers Andy


Use the TIdSocketHandle.AddMulticastMembership() method instead (if your version of Indy 10 does not have that method available, then you will have to update to a newer snapshot first), eg:

inUDPServer.Binding.AddMulticastMembership('Group IP address');

It adds the TIdSocketHandle.IP address to the membership of the specified Group IP. IPs can be specified as either IPv4 or IPv6, depending on the setting of the TIdSocketHandle.IPVersion property.

Alternatively, consider using the TIdIPMCastServer and TIdIPMCastClient components instead of TIdUDPServer directly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜