(07-19-2024, 07:53 AM)Ahmed Sayed Wrote: I see that it binds to 2 sockets one for ipv4 and the other for ipv6
Yes, but only when the Bindings collection is empty when activating the server, and only if the OS supports binding both IPv4 and IPv6 at the same time.
(07-19-2024, 07:53 AM)Ahmed Sayed Wrote: is there a way where I can make it bind only to ipv4 I don't need v6.
Yes - simply add an IPv4 item to the Bindings collection before activating the server (that is the "optional" comment in my previous example), eg:
Code:
IdTCPServer.Bindings.Clear;
// '' means the same as '0.0.0.0.0' to bind to all local adapters.
// You can also use a specific adapter's IP instead...
IdTCPServer.Bindings.Add.SetBinding('', 0, Id_IPv4);
IdTCPServer.Active := True;
for I := 0 to IdTCPServer.Bindings.Count-1 do begin
WriteLn('Listening on ' + IdTCPServer.Bindings[I].IP + ':' + IntToStr(IdTCPServer.Bindings[I].Port));
end;
(07-19-2024, 07:53 AM)Ahmed Sayed Wrote: Also, is there a limit on the number of ephemeral ports generated by the OS as you said?
Yes, of course there is a limit, as ports are a finite resource. The actual range of ports available differs from one OS to another, and even OS configurations.