[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 144
  • Last Modified:

NT/Internet problems Part 1

An application with a TClientSocket component sends a full path (incl. filename) to an application with a TServerSocket component on another machine. How do I convert the IP# in serversocket.socket.remoteaddress to the machine name (eg. \\MyMachine) ?

This has to work under NT 4.0
0
hatecapletters
Asked:
hatecapletters
1 Solution
 
EpsylonCommented:
uses WinSock;

function GetHostName(name : string) : string;
var
wsdata : TWSAData;
  he : PHostEnt;
  ip : TInAddr;          
begin
  WSAStartup(MakeWord(1, 1), wsdata);
  ip.S_addr := inet_addr(PChar(name));
  he := gethostbyaddr(@ip.S_un_b, 4, AF_INET);      
  if he<>nil then
    Result := string(he.h_name)
  else
    Result := IntToStr(WSAGetLastError);
  WSACleanup();
end;
0
 
hatecaplettersAuthor Commented:
works like a charm :-)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now