Voting

: max(zero, three)?
(Example: nine)

The Note You're Voting On

peter at videoripper dot org
15 years ago
This will give you a simple port-checker.

Note that on production-machines, you might want to alter the error reporting-level,
since unsuccessful connects will give you a "No connection could be made because
the target machine actively refused it"-error in the log.

Under Windows, make sure you enable the php_sockets.dll extension in your php.ini.

<?php
$address
=$_SERVER['REMOTE_ADDR'];

if (isset(
$_REQUEST['port']) and
(!
strlen($_REQUEST['port'])==0))
$port=$_REQUEST['port'];
else
unset(
$port);

if (isset(
$port) and
(
$socket=socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) and
(
socket_connect($socket, $address, $port)))
{
$text="Connection successful on IP $address, port $port";
socket_close($socket);
}
else
$text="Unable to connect<pre>".socket_strerror(socket_last_error())."</pre>";

echo
"<html><head></head><body>".
$text.
"</body></html>";
?>

Greetz,

Peter.

<< Back to user notes page

To Top