forLord
asked on
How can I change the longint to ipaddress string like '192.168.1.103'?
function my_ip_address:longint;
const
bufsize=255;
var
buf: pointer;
//str: string;
RemoteHost : PHostEnt; (* No, don't free it! *)
begin
buf:=NIL;
try
getmem(buf,bufsize);
winsock.gethostname(buf,bu fsize); (* this one maybe without domain *)
RemoteHost:=Winsock.GetHos tByName(bu f);
if RemoteHost=NIL then
my_ip_address:=winsock.hto nl($070000 01) (* 127.0.0.1 *)
else
my_ip_address:=longint(poi nter(Remot eHost^.h_a ddr_list^) ^);
//str:= inet_addr(pointer(RemoteHo st^.h_addr _list^)^);
finally
if buf<>NIL then freemem(buf,bufsize);
end;
result:=winsock.ntohl(resu lt);
end;
const
bufsize=255;
var
buf: pointer;
//str: string;
RemoteHost : PHostEnt; (* No, don't free it! *)
begin
buf:=NIL;
try
getmem(buf,bufsize);
winsock.gethostname(buf,bu
RemoteHost:=Winsock.GetHos
if RemoteHost=NIL then
my_ip_address:=winsock.hto
else
my_ip_address:=longint(poi
//str:= inet_addr(pointer(RemoteHo
finally
if buf<>NIL then freemem(buf,bufsize);
end;
result:=winsock.ntohl(resu
end;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
My Default GetWay:192.168.1.1 vpn host
my ip :192.168.1.103 in vpn
The GetWay above 192.168.1.1 : 218.86.198.1
mask:225.225.225.0
first DNS:202.98.192.68
second DNS:192.168.1.11
with the two function run
I got getway as 128.1.1.223 why?
where did 128.1.1.223 come from?
and I ping 128.1.1.223 I cant ping through it.
I can ping through 192.168.1.1 192.168.1.103 218.86.198.1 first DNS:202.98.192.68
second DNS:192.168.1.11