?
Solved

Checking if a port is open?

Posted on 2004-08-17
2
Medium Priority
?
871 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 2000 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

777 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