Carsten A. Arnholm
2014-09-29 19:51:40 UTC
Hi
I have been struggling to get the "better method" to find the local LAN
IP address to work, i.e. the method described at
http://wiki.wxwidgets.org/Getting_IP_Address_Of_Host
i.e.
wxIPV4address addr;
addr.Hostname(wxGetFullHostName());
wxString ipAddr = addr.IPAddress();
I am trying on two machines running Windows and Kubuntu, and both are
failing, but in different ways. Both machines are desktops with only one
network card.
Win7, wx3.0.1., MS VC2010 Express compiler
==========================================
The code above returns "255.255.255.255" only, which isn't so useful.
According to the Win7 control panel, the "Computer name", "Full computer
name" and "Computer description" are all "Rustad6THINK" exactly.
However, wxGetFullHostName() returns "Rustad6THINK.Inteno", which is
incorrect. I recognise "Inteno" as my ISP broadband router. So I suspect
wxGetFullHostName() isn't 100% reliable. However...
wxIPV4address addr;
addr.Hostname(wxGetHostName());
wxString ipAddr = addr.IPAddress();
.. returns the desired result, the local LAN address is properly
resolved, apparently because wxGetHostName() resolves the computer name
correctly, unlike wxGetFullHostName().
Kubuntu 14.04, wx3.0.1, g++
===========================
Different machine, same network. Both examples above fail.
wxGetFullHostName() and wxGetHostName() both return the host name
correctly, but the IP adress I get is simply 127.0.1.1 in both cases.
Is there really no way to do this properly?
Best regards
Carsten Arnholm.
I have been struggling to get the "better method" to find the local LAN
IP address to work, i.e. the method described at
http://wiki.wxwidgets.org/Getting_IP_Address_Of_Host
i.e.
wxIPV4address addr;
addr.Hostname(wxGetFullHostName());
wxString ipAddr = addr.IPAddress();
I am trying on two machines running Windows and Kubuntu, and both are
failing, but in different ways. Both machines are desktops with only one
network card.
Win7, wx3.0.1., MS VC2010 Express compiler
==========================================
The code above returns "255.255.255.255" only, which isn't so useful.
According to the Win7 control panel, the "Computer name", "Full computer
name" and "Computer description" are all "Rustad6THINK" exactly.
However, wxGetFullHostName() returns "Rustad6THINK.Inteno", which is
incorrect. I recognise "Inteno" as my ISP broadband router. So I suspect
wxGetFullHostName() isn't 100% reliable. However...
wxIPV4address addr;
addr.Hostname(wxGetHostName());
wxString ipAddr = addr.IPAddress();
.. returns the desired result, the local LAN address is properly
resolved, apparently because wxGetHostName() resolves the computer name
correctly, unlike wxGetFullHostName().
Kubuntu 14.04, wx3.0.1, g++
===========================
Different machine, same network. Both examples above fail.
wxGetFullHostName() and wxGetHostName() both return the host name
correctly, but the IP adress I get is simply 127.0.1.1 in both cases.
Is there really no way to do this properly?
Best regards
Carsten Arnholm.
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.
To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.
To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users