BroadcastListenerrIPv6.IPVersion := Id_IPv6
or BroadcastListenerIPv6.Bindings.Items[I].IPVersion := Id_IPv6
to match the IP you are assigning? Why do you have a Binding created at design-time if you are just going to overwrite it at runtime? You may as well just use Bindings.Add()
at runtime instead.
const
cMulticastGroupIPv6 = 'FF02:0:0:0:0:0:0:1';
procedure TForm1.FormCreate(Sender: TObject);
var
I: Integer;
LBinding: TIdSocketHandle;
begin
FLocalAddresses := TIdStackLocalAddressList.Create;
GStack.GetLocalAddressList(FLocalAddresses);
BroadcastServerIPv6.Port := 6000;
BroadcastServerIPv6.MulticastGroup := cMulticastGroupIPv6;
BroadcastServerIPv6.Active := True;
BroadcastListenerIPv6.DefaultPort := 6000;
BroadcastListenerIPv6.IPVersion := TIdIPVersion.Id_IPv6;
BroadcastListenerIPv6.MulticastGroup := cMulticastGroupIPv6;
BroadcastListenerIPv6.Bindings.Clear;
for I := 0 to FLocalAddresses.Count - 1 do
begin
if FLocalAddresses[I].IPVersion = TIdIPVersion.Id_IPv6 then
begin
LBinding := BroadcastListenerIPv6.Bindings.Add;
LBinding.IP := FLocalAddresses[I].IPAddress;
LBinding.IPVersion := TIdIPVersion.Id_IPv6;
LBinding.Port := BroadcastListenerIPv6.DefaultPort;
end;
end;
BroadcastListenerIPv6.Active := True;
end;
gethostname()
or getaddrinfo()
directly (which are wrapped by Indy's TIdStack.HostByName()
method), which uses the OS's own DNS resolver; and then 2) resolve the HostName using gethostbyaddr()
or getnameinfo()
(which are wrapped by Indy's TIdStack.HostByAddress()
method), which also use the OS's own DNS resolver. Yes, TIdDNSResolver
requires a Host
, because it implements DNS manually from scratch, and doesn't use the OS resolver at all. You can query your OS's DNS server(s), or let the user specify them.
TIdSync
still works, but is deprecated because TThread::Synchronize()
with an anonymous procedure accomplishes the same thing that TIdSync
was originally intended for. Read Embarcadero's documentation for How to Handle Delphi Anonymous Methods in C++.