Check wether a port is open using PHP

I saw Tony running this test and didn’t really understand what was going on. Well, this explains it,or at least tries to 😛

Open and Free Source!

You need to replace the
$address =””;
$port = ‘port_number’;

/*Code starts*/
/*port test*/

$port = ‘456’;
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”;
else  {
$text=”Unable  connect<pre>”.socket_strerror(socket_last_error()).”</pre>”;
echo “<html><head></head><body>”.

/*code ends*/
code courtesy:

How to test :- Copy this code to a file say, porttest.php, change the $address , $port to the required and put it somewhere accessible by your server , like /var/www/ in linux. And run the same by opening localhost/porttest.php

View original post