[fpc-pascal] Linux getifaddrs

Mark Morgan Lloyd markMLl.fpc-pascal at telemetry.co.uk
Thu Mar 1 17:39:09 CET 2018


On 01/03/18 15:15, Brian wrote:
> Do you know of any kernel functions that would return the current IP address?

I think you're looking for something like SIOCGIFADDR in netdevice(7), 
but it's not necessarily what you want. You need to take into account 
that a single host might have multiple interfaces, and that each 
interface might have multiple assigned IP addresses (aliases in IP4 
terms). In practical terms you almost always either want to tell a 
program which of the available IP addresses to use or let it use 
0.0.0.0, and don't for one moment dream of embedding an IP address 
inside your comms protocol since you'll end up with a proxying nightmare 
like VOIP.

The only time I've really needed to play with this was when trying to 
work out a machine's local neighbours so I could see whether they 
responded to a non-standard UDP protocol.

-- 
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]



More information about the fpc-pascal mailing list