Has anyone translated* getifaddrs* function to Free Pascal ?
http://man7.org/linux/man-pages/man3/getifaddrs.3.html
Thanks
Brian

Mailing lists / fpc-pascal / 2018-02
6 messages · 4 people · –
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
Has anyone translated* getifaddrs* function to Free Pascal ?
http://man7.org/linux/man-pages/man3/getifaddrs.3.html
Thanks
Brian
Brian wroteHas anyone translated* getifaddrs* function to Free Pascal ? http://man7.org/linux/man-pages/man3/getifaddrs.3.html
Not to my knowledge.
It's not a kernel function, but a Libc function, as far as I can see ?
Michael.
Do you know of any kernel functions that would return the current IP address ?
Thanks
Brian
Not to my knowledge. It's not a kernel function, but a Libc function, as far as I can see…
Op 01-03-2018 00:08 schreef Michael Van Canneyt:
You might find some more information here:
http://forum.lazarus.freepascal.org/index.php/topic,30062.msg190832.html#msg190832
(please note the type for libc.co)
There is also a function in Synapse (ResolveNameToIP()) which could resolve the localhost to all local IPs.
(and I'm sure there is also something in Indy)
Rik
Do you know of any kernel functions that would return the current IP address ? Thanks…
Brian wroteDo 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.
Thanks for all the suggestions but , I found and example which I have modified for my needs. Currently using Synapse but it only returns the loopback IP address since in my case the ports eth0 and eth1 are both static IP's.
It is a bit odd that something like this isn't incorporated into Free Pascal sockets.
Thanks
Brian