Jump to content

fsocket & fread with UDP


Lectrician

Recommended Posts

I have a script which runs to check TCP connections are open on a certain port.

 

I had a need to check UDP connections, and so altered it as below.

 

This works fine on my home Microsoft SBS IIS server, but timesout on my 1and1 hosting.

 

  function ping($host, $port, $protocol, $timeout) {    if($protocol == "udp"){ $host = "udp://$host"; }     $tB = microtime(true);     $fP = fsockopen($host, $port, $errno, $errstr, $timeout);     if(!$fP){ return "tcpdown"; }    if($protocol == "udp"){      fwrite($fP, "\n");      $fread = fread($fP, 26);      fclose($fP);       if($fread == ""){ return "udpdown"; }     }     $tA = microtime(true);     return round((($tA - $tB) * 1000), 0);   } 

 
Any ideas why this timesout?
 
Thanks.
Link to comment
https://forums.phpfreaks.com/topic/287976-fsocket-fread-with-udp/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.