I use the following code, results are correct.
I am working on LAN with just 3 machines.
Also that network is not connected to the internet.
It takes 16 secs for only this lineHostEnt := gethostbyaddr(@SockAddrIn.sin_addr.S_addr, 4, AF_INET); GetHostByName(PChar(HostName)); is instant (delphitricks.com/source-code/internet/…) function IPAddrToName(IPAddr: string): string; var SockAddrIn: TSockAddrIn; HostEnt: PHostEnt; WSAData: TWSAData; begin WSAStartup($101, WSAData); SockAddrIn.sin_addr.s_addr := inet_addr(PChar(IPAddr)); HostEnt := gethostbyaddr(@SockAddrIn.sin_addr.S_addr, 4, AF_INET); if HostEnt <> nil then Result := StrPas(Hostent^.h_name) else Result := ''; end;
https://stackoverflow.com/questions/3446879/gethostbyaddr-too-slow
Result of
ipcofig /all
(from machine running gethostbyaddr)Windows IP Configuration Host Name . . . . . . . . . . . . :YYY Primary Dns Suffix . . . . . . . : Node Type . . . . . . . . . . . . : Unknown IP Routing Enabled. . . . . . . . : No WINS Proxy Enabled. . . . . . . . : No Ethernet adapter Local Area Connection: Connection-specific DNS Suffix . : Description . . . . . . . . . . . : Realtek RTL8139/810x Family Fast Ethernet NIC Physical Address. . . . . . . . . : 00-XX-XX-XX-xx-XX Dhcp Enabled. . . . . . . . . . . : No IP Address. . . . . . . . . . . . : 192.168.1.123 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : 192.168.1.1 DNS Servers . . . . . . . . . . . : 202.149.208.90 202.149.208.11
Answer
It could be that you are having two dns servers, and first one is not working so your windows machine waits for timeout from first host (10+secs) and then tries second dns.
Try changing dns to something else, like some public dns service and see if it makes a difference.
Attribution
Source : Link , Question Author : Allan Fernandes , Answer Author : damir