SFML community forums
Help => Network => Topic started by: zac on January 18, 2009, 03:55:06 pm
-
Looking for an alternative to whatismyip.org (which is not reachable, at least from here)...
sf::IPAddress __getIpFromCheckipdyndns_org()
{
IPAddress PublicAddress;
Http Server("http://checkip.dyndns.org");
Http::Request Request(Http::Request::Get, "/");
Http::Response Page = Server.SendRequest(Request,4.f);
if(Page.GetStatus() == Http::Response::Ok)
{
string s = Page.GetBody();
size_t ind = s.find_first_of("0123456789");
if(ind != string::npos)
{
size_t indl = s.find_first_not_of("0123456789.",ind);
string sub = s.substr(ind,indl-ind);
if(sub.length() >= 7 && sub.length() <= 15)
{
PublicAddress = sub;
}
}
}
return PublicAddress;
}
Any idea why it is not working (the page is reachable in my Browser), but immediately returning an empty page??
-
Your code works perfectly on my machine.
-
http://www.dyndns.com/developers/checkip.html
Checks must be spaced 10 minutes apart to help reduce server load
Sure you conformed to this?
-
Thats not that good... ;)
Okay. It is no possible alternative, I think ;)
We have to find another way - whatismyip.org still does not respond. (It least I get stuck on creating a connection).
-
Finding your IP is as simple as connecting to any host that is configured to reply with your remote IP. It's easy to set up your own host to do this, the only requirement is a static IP or DNS so the clients know where to connect.
For instance if you have a web server with PHP, it's as easy as
<?php echo $_SERVER['REMOTE_ADDR']; ?>
In fact, I just did that in 3 minutes: http://corexii.com/ip/
You can use that for development if you can't make your own; However, do not use it for a public distribution, I don't know if I can cope with the traffic.
-
The server www.whatismyip.org is currently unreachable, and it is indeed very simple to make a webpage return an IP address, so I added one on the SFML website and added it as a fallback in IPAddress::GetPublicAddress :)
-
Okay, great :).
-
I just thought I'd add another alternative in case anyone needs one:
http://www.showmyip.com/simple
-
www.whatismyip.com is the one i always go... he is table since many year...
http://whatismyip.com/automation/n09230945.asp