Solved

Checking if a port is open?

Posted on 2004-08-17
2
869 Views
Last Modified: 2007-12-19
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
Comment
Question by:gunghoassassin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 27

Accepted Solution

by:
Diablo84 earned 500 total points
ID: 11821908
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
 
LVL 27

Expert Comment

by:Diablo84
ID: 11821929
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question