Dear all,
My function below works fine on Windows (XP+Vista), but never succeeds on
Mac Os (10.5) or Ubuntu (9.04). Does anybody know why?
// SDLNET_Init() has been called!
string DetermineIpAddress(void)
{
string s = "unknown";
const char *host;
IPaddress address;
Uint16 port(80);
Uint32 ipaddr;
char c[256];
address.host = 0;
address.port = 69;
if( (host = SDLNet_ResolveIP(&address)) != NULL )
{
// Windows will get to here, Mac Os & Ubuntu won't
SDLNet_ResolveHost(&address, host, port);
ipaddr=SDL_SwapBE32(address.host);
sprintf(c, "%d.%d.%d.%d", ipaddr>>24, (ipaddr>>16)&0xff,
(ipaddr>>8)&0xff, ipaddr&0xff);
s = c;
}
return s;
}
Thanks for the help,
Maarten