Check Connectivity Of Http Port Of Given Ip Address

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tarak
    New Member
    • Sep 2007
    • 1

    Check Connectivity Of Http Port Of Given Ip Address

    Hi, I am working on a site that wants to provide facility to check whether http port and ftp port of given ip address is working or not. I will provide an ip address i need to check status of all ports
  • gregerly
    Recognized Expert New Member
    • Sep 2006
    • 192

    #2
    Originally posted by tarak
    Hi, I am working on a site that wants to provide facility to check whether http port and ftp port of given ip address is working or not. I will provide an ip address i need to check status of all ports
    One way you could test this would be:

    [PHP]
    $host="0.0.0.0" ;
    $ports = array(21=>'ftp' ,80=>'http');
    $timeout = 5.0;
    foreach($ports as $port=>$descrip tion) {
    $socket = @fsockopen($hos t, $port, $errno, $errstr, $timeout);
    if ($errno) {
    echo "ports not open<br>";
    } else {
    echo "port is open<br>";
    }
    @fclose($socket );
    }[/PHP]

    I just tested this on my server and it was detecting if the ports were open or closed properly. Let me know if you have any issues, but I think this may get you where you need to go.

    Greg

    Comment

    Working...