Re: ./EuGTK/GtkEngine.e to Irv
- Posted by jimcbrown (admin) Apr 22, 2015
- 1940 views
OK, what is the correct way to get my ip address if I am connected to a network but NOT to the internet?
For example, I run my Eu webserver to make music available locally. I don't think anyone at whitehouse.gov wants to listen (to music, that is, they're already listening to everything else...).
Edit: a cross-platform solution would be nice.
One way is to get the hostname of the computer itself, then get the ip address for that hostname.
The 2nd step is easy to do - std/net/dns.e:host_by_name() will do the trick. However, we don't have the gethostname() function wrapped, even though it is portable: https://msdn.microsoft.com/en-us/library/windows/desktop/ms738527(v=vs.85).aspx and http://linux.die.net/man/2/gethostname
What's the purpose of getting the ip address though? Just checking for a live internet connectino is different from getting the ip to host a public webserver or something, which is different again from hosting a local fileserver that's not visible beyon the local lan, etc etc. Maybe I'm not understanding the scope here.