Sample code for 30+ languages & platforms
Delphi DLL

Resolve a Hostname to an IP Address

See more Socket/SSL/TLS Examples

Demonstrates Socket.DnsLookup, which resolves a hostname and returns one numeric IP address.

Background. A maxWaitMs of 0 waits indefinitely; a positive value bounds the wait. Resolved results may be served from Chilkat's process-wide DNS cache.

Chilkat Delphi DLL Downloads

Delphi DLL
var
socket: HCkSocket;
ipAddress: PWideChar;

begin
socket := CkSocket_Create();

//  Resolve a hostname to a numeric IP address, waiting up to 5 seconds.
ipAddress := CkSocket__dnsLookup(socket,'example.com',5000);
if (CkSocket_getLastMethodSuccess(socket) = False) then
  begin
    Memo1.Lines.Add(CkSocket__lastErrorText(socket));
    Exit;
  end;
Memo1.Lines.Add('Resolved IP address: ' + ipAddress);

CkSocket_Dispose(socket);