Lectrician Posted April 23, 2014 Share Posted April 23, 2014 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. Quote Link to comment https://forums.phpfreaks.com/topic/287976-fsocket-fread-with-udp/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.