Mega Code Archive

 
Categories / Delphi / LAN Web TCP
 

How to get the IP from a given URL

Title: How to get the IP from a given URL uses Winsock; function IAddrToHostName(const IP: string): string; var i: Integer; p: PHostEnt; begin Result := ''; i := inet_addr(PChar(IP)); if i u_long(INADDR_NONE) then begin p := GetHostByAddr(@i, SizeOf(Integer), PF_INET); if p nil then Result := p^.h_name; end else Result := 'Invalid IP address'; end;