Hello I am having a dikens of a time getting my IP address on the machineHere's my code that I use:
that I am working on. I've looked in the mailing list and I found something
that I've been toying with but still I cannot get the xxx.xxx.xxx.xxx style
name I can only get my machine name. Here's what I have which I can get the
names but not the byte code address.
I know how to do this in python gethostbyname(gethostname()) by I'm having a
hard time with this.
uses sockets, errors, inet;
{ ... functions cut not important to your question ... }
function Open(host : string; port : integer) : integer;
var
h : THost;
addr : TInetSockAddr;
begin
h.NameLookup(host);
if h.LastError <> 0 then
begin
Open := 1;
Exit;
end;
addr.family := AF_INET;
addr.port := ShortHostToNet(port);
addr.addr := HostTonet(longint(h.IPAddress));
sock := Socket(AF_INET, SOCK_STREAM, 0);
if Not Connect(sock, addr, sin, sout) then
begin
Open := 2;
Exit;
end;
rewrite(sout);
reset(sin);
Open := 0;
end;
Hope this helps.
Jeremy
_______________________________________________ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal