一个例子:
function TWebStatistic.GetRemoteHost(RemoteAddr : String): String;
var
SockAddrIn : TSockAddrIn;
HostEnt: PHostEnt;
WSAData: TWSAData;
begin
if (RemoteHost='127.0.0.1') then
result:=''
else
begin
WSAStartup($101, WSAData);
SockAddrIn.sin_addr.s_addr:= inet_addr(PChar(RemoteAddr));
Timer1.Enabled:=True;
HostEnt:= gethostbyaddr(@SockAddrIn.sin_addr.S_addr, 4, AF_INET);
Timer1.Enabled:=False;
if HostEnt<>nil then
result:=StrPas(Hostent^.h_name)
else
result:='';
WSACleanup;
end;
end;