[fpc-pascal] Find out local IP adress

David W Noon david.w.noon at ntlworld.com
Sun Mar 22 21:21:19 CET 2009

On Sun, 2009-03-22 at 20:36 +0100, Rainer Stratmann wrote:

> Am Sonntag, 22. März 2009 20:24 schrieb Jonas Maebe:
> > On 22 Mar 2009, at 20:21, Rainer Stratmann wrote:
> > > May be there exists another way to find out the local IP adress.
> >
> > "The" local ip address does not exist. A system can have multiple
> > network cards, there can be vpn tunnels, NAT gateways to other
> > networks and virtual machines, ... Which of these local addresses are
> > you interested in?
> The IP adress of the network card(s).

Since the machine can have several NICs, you first need to decide which
one. If your machine has only one, then this is easy.

There is an ioctl for querying the IP address of a given Ethernet
interface, for which you need to open a socket. It is SIOCGIFADDR. See:
man 2 ioctl_list

If you want some C++ code to perform this, I can send you some via
private email. It's up to you to translate it to Pascal.


Dave  [RLU #314465]
david.w.noon at ntlworld.com (David W Noon)

More information about the fpc-pascal mailing list