caymon 0 Posted April 21, 2021 In an TIdUDPServer, we can select the IP address, where the server listens to using (for example): IdUDPServer.Bindings.Add.IP := ...; If I set one of the several addresses of the system, like: IdUDPServer.Bindings.Add.IP := '2017::7690:5000:0:1'; Then the UDPServer receives the packets sent to that address, the OnUDPRead handler is called and I can verify that the values of ABinding.IP, ABinding.PeerIP and ABinding.PeerPort are all correct. If IdUDPServer.Bindings.Add.IP is set to a blank string, then IdUDPServer should bind to all available local IPs. But, this doesn't seem to be true, the OnUDPRead is not called as if the UDPServer would not receive the packets sent to the address above. What could be the reason? Thank you. Using 10.4.2 on W10 Share this post Link to post
Remy Lebeau 1393 Posted April 21, 2021 (edited) 5 hours ago, caymon said: If IdUDPServer.Bindings.Add.IP is set to a blank string, then IdUDPServer should bind to all available local IPs. Almost. It would be more accurate to say that it binds to all local network adapters for the Binding's specified IPVersion. The IPVersion is set to IPv4 by default (see the ID_DEFAULT_IP_VERSION constant in IdGlobal.pas). You would need 2 separate Binding objects to bind to all IPv4 and IPv6 adapters at the same time, as TIdUDPServer would have to create separate IPv4 and IPv6 listening sockets (Indy does not support dual-stack sockets at this time: ticket #29). For example: IdUDPServer.DefaultPort := ...; with IdUDPServer.Bindings.Add do begin IP := ...; IPVersion := Id_IPv4; end; with IdUDPServer.Bindings.Add do begin IP := ...; IPVersion := Id_IPv6; end; If you don't create any Bindings at all, TIdUDPServer will create 1 or 2 default Binding objects for you, depending on whether the underlying platform allows separate IPv4+IPv6 sockets to be bound on all adapters on the same port at the same time (not all do, ie Linux and Android do not, but Windows does). Quote But, this doesn't seem to be true, the OnUDPRead is not called as if the UDPServer would not receive the packets sent to the address above. The above IP is an IPv6 address, so I'm guessing you have not created an IPv6 Binding to listen on. You can't bind an IPv4-only socket to IPv6 adapters, and vice versa. Edited April 21, 2021 by Remy Lebeau Share this post Link to post