I had written a function to get Host Ip address.
wxString BasicFrame::GetMyIp()
{
wxIPV4address MyIp;
wxString MyHostName = MyIp.Hostname(); /* Get my hostname */
wxString sMyIp;
bool bRet;
bRet = MyIp.Hostname(MyHostName); /* Set MyIp to my Hostname */
if (bRet == true)
{
sMyIp = MyIp.IPAddress(); /* Get Ip address of my Hostname */
}
else
{
sMyIp = "0.0.0.0";
}
return sMyIp;
}
The code works perfectly for Windows. But I have a problem in linux. It gives a warning "Trying to solve NULL hostname:Giving up" and returns 0.0.0.0 .When I debuged the program I found out that MyIp.Hostname() is returning false.
Thanks and regards