Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 879
  • Last Modified:

Checking if a port is open?

What's a good way to check if a port is open in php?  I'm trying to write a script that makes sure a server is online.
0
gunghoassassin
Asked:
gunghoassassin
  • 2
1 Solution
 
Diablo84Commented:
A simple method would be using fsockopen (http://www.php.net/manual/en/function.fsockopen.php)

eg.

<?php
$url = "http://www.domain.com";
$port = 80;
$fp = fsockopen($url, $port);
if (!$fp) {
 echo "server offline";
}
?>
0
 
Diablo84Commented:
Be sure to check out the manual page (see link above) and the user comments at the bottom of the page for more examples of the functions use
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now