Hola,
En
este enlace puede contrarse la unidad "SimpleTcp" escrita por
Piechnat. En dicha unidad existen dos funciones que no sé porqué a mí no me van bien, pero, que, puede que a ti te vayan bien, o, cuando menos, te da alguna que otra idea:
Código Delphi
[-]
uses
WinSock;
function HostToIP(Host: string): string;
var
He: PHostEnt;
InAddr: TInAddr;
begin
Result := '';
He := gethostbyname(PChar(Host));
if He <> nil then
begin
Move(He^.h_addr_list^^, InAddr.S_addr, He^.h_length);
Result := string(inet_ntoa(InAddr));
end;
end;
function IPToHost(IP: string): string;
var
He: PHostEnt;
Addr: Integer;
begin
Result := IP;
Addr := inet_addr(PChar(IP));
He:= gethostbyaddr(@Addr, SizeOf(Addr), AF_INET);
if He <> nil then Result := He^.h_name;
end;