Adding a time out for empty results?
Posted: Tue Nov 28, 2006 11:46 am
I've created a google map that maps my users by IP address. I query hostip.info to get their geolocation but the problem is some of the results come back empty and hostip.info takes awhile to return the empty results.
I've done some research about sockets but I'm not sure how I would use it or even if I should.
Keep in mind that this code gives succesful results most of the time, but takes too long to time out if the results come back empty.
Anywho, here's my code inside my loop that provides the latitude and longitude for my map:
Any ideas?
I've done some research about sockets but I'm not sure how I would use it or even if I should.
Keep in mind that this code gives succesful results most of the time, but takes too long to time out if the results come back empty.
Anywho, here's my code inside my loop that provides the latitude and longitude for my map:
Code: Select all
$results[$i]=file_get_contents("http://www.hostip.info/api/get.html?ip=$ip&position=true");
preg_match('/Latitude: (.*)/', $results[$i], $lat);
preg_match('/Longitude: (.*)/', $results[$i], $lon);Any ideas?