Ver Mensaje Individual
  #3  
Antiguo 05-07-2006
Avatar de dec
dec dec is offline
Moderador
 
Registrado: dic 2004
Ubicación: Alcobendas, Madrid, España
Posts: 13.107
Reputación: 34
dec Tiene un aura espectaculardec Tiene un aura espectacular
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;
__________________
David Esperalta
www.decsoftutils.com
Responder Con Cita