Hi Guys,
I have this code right here to retrive the IP-address from a hostname:
it works fine and gives me the IP address.Code:program Project1; {$APPTYPE CONSOLE} uses SysUtils, winsock; function GetIPFromHost(const HostName: string): string; type TaPInAddr = array[0..10] of PInAddr; PaPInAddr = ^TaPInAddr; var phe: PHostEnt; pptr: PaPInAddr; i: Integer; begin Result := ''; phe := GetHostByName(PChar(HostName)); if phe = nil then Exit; pPtr := PaPInAddr(phe^.h_addr_list); i := 0; while pPtr^[i] <> nil do begin Result := inet_ntoa(pptr^[i]^); Inc(i); end; end; var wsaData: TWSAData; begin if (WSAStartup($0202, wsaData) <> 0) then begin Exit; end; while true do begin sleep (1000); GetIPFromHost ('localhost'); end;
Unfort. I need this function a couple of times to compare a DNS with an IP-address.
For some reason I get a big Memory Leak and the memory of my program increases very fast.
Why is that and how can I free the memory?
Thanks in advance.


LinkBack URL
About LinkBacks
Reply With Quote
