[fpc-pascal]Local Ip Address
michalis at camelot.homedns.org
Mon Feb 23 16:45:11 CET 2004
Crabtree, Chad wrote:
> Hello I am having a dikens of a time getting my IP address on the machine
> 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.
> program get_ip;
> uses sockets,winsock;
> ac: array[0..255] of char;
I'm attaching some quick&dirty hacks of your code that make everything
working. It will also work on Linux (and other UNIXes, probably) when
you replace winsock with Libc (in fact, I was doing my fixes while
sitting on Linux... but I just checked this on Windows and it works).
Note that it may return as address '127.0.0.1' which may or may not be
usable to you.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
More information about the fpc-pascal