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. Link to comment https://forums.phpfreaks.com/topic/287976-fsocket-fread-with-udp/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.