Take this fragment:
Code: Select all
wxIPV4address MyIp;
wxString MyHostName = MyIp.Hostname(); /* Get my hostname */
What makes you believe that this will set MyHostName to your hostname? Neither in wxGTK nor in the documentation did I find anything that says that the default constructor of wxIPV4address would set the object to the machine's IP, so that you could retrieve its hostname with wxIPV4address::Hostname().
I didn't find this explicitely in the documentation either, but a glance at the wxGTK source hints at that the default constructor of wxIPV4address will set the IP to all zeros and the hostname to the empty string (which is why you get that error message).
This makes me wonder why this works on windows. At best, this would be an undocumented and unportable feature.
EDIT: This works for me (linux/wxGTK):
Code: Select all
#include <wx/socket.h>
#include <wx/utils.h>
wxString hostname = wxGetHostName(); /* or wxGetFullHostName() */
wxIPV4address ipaddr;
ipaddr.Hostname(hostname);
wxString ipstring = ipaddr.IPAddress();