[fpc-pascal] lNet getting the local IP

Marco van de Voort marcov at stack.nl
Wed Oct 6 16:06:54 CEST 2010


In our previous episode, Felipe Monteiro de Carvalho said:

> function ChessGetLocalIP(): string;

>         VProcess.CommandLine :=
>           'sh -c "ifconfig eth0 | awk ''/inet end/ {print $3}''"';


Fails if eth0 is not the primary NIC. Doesn't work on non-linux (that use
other ethernet naming schemes)

A safe solution will probably boil down to walking the list of ethernet
adapters and routes to find the default route on *nix.



More information about the fpc-pascal mailing list