UDP sockets will sometimes appear to have opened without an error, even if the remote host is unreachable. The error will only become apparent when you read or write data to/from the socket. The reason for this is because UDP is a "connectionless" protocol, which means that the operating system does not try to establish a link for the socket until it actually needs to send or receive data.

so basically you need to send a small 8 bit buffer for your host to actually attempt a connection

try doing something like:

PHP Code: 
try
    {
        
$socket fsockopen($host,$port,$e_number,$e_string,$timeout);
        
fwrite($socket,str_repeat(" ",8));
    }catch(
Exception $e)
    {
        
//Not a valid domain more than likly!
        
return false;
    } 
if im right, http is based over RTP connections and not UDP, im not sure if RTP is also connectionless
litewarez Reviewed by litewarez on . help with a php script !! hi guyz just for practice i started to code a small script which checks if the remote host or site is online ... and then it gives back the result ... here : http://isonline.warezsociety.org/index.php when i test it on my pc with easyphp everything goes well , but i uploaded the script to my host and many times when i submit a website which doesnt exist it says its online ... on my pc everything was ok never got wrong answer .... any idea ?? Rating: 5