cidero Posted July 6, 2010 Share Posted July 6, 2010 Hi, I am currently writing a testscript to check various services for availability. I use this to check a HTTP webserver: $fp = @fsockopen($host, $port, $errno, $errstr, $timeout); stream_set_timeout($fp, 5); if (!$fp) { $output .= "$errstr ($errno)\n"; } else { $out = "GET / HTTP/1.1\r\n"; $out .= "Host: ".$host."\r\n"; $out .= "Connection: Close\r\n\r\n"; fwrite($fp, $out); while (!feof($fp)) { $output .= fgets($fp, 128); } @fclose($fp); } In return I get the HTML of the website in the $output variable. If I want to check a HTTPS webserver I just add a "ssl://" in front of the $host in the first line. To check SSH, I do this: { $fp = @fsockopen($host, $port, $errno, $errstr, $timeout); stream_set_timeout($fp, 5); if (!$fp) { $output .= "$errstr ($errno)\n"; } else { while (!feof($fp)) { $output .= fgets($fp, 128); } @fclose($fp); } In return I get the SSH welcome banner, for example “SSH-2.0-OpenSSH_4.3 “. But how can I check OpenVPN servers? I guess the problem is that OpenVPN uses UDP instead of TCP. The php documentation about fsockopen() says that I have to put a "udp://" in front of the $host variable. But it doesn't work. I guess I have to send some kind of "Hello" message like in the HTTP example. Does anyone have an idea? As an example, OpenVPN servers should listen on 216.218.211.158:8047 and 69.22.186.19:8047. Thank you very much in advance, Lars Link to comment https://forums.phpfreaks.com/topic/206850-howto-check-with-fsockopen-if-a-openvpn-server-is-reachable/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.