Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Checking port status using php
November 3, 2008, 11:38 pm
rate this thread
The problem is that not all of them are necessarily on the network which
causes php script to execute for extended periods of time. Is there a way
to either specify a timeout on a command such as ssh_connect or
alternatively is there a command to check if a certain port (22 in my
case) is accepting connections. Then it's a simple matter of using if then
to execute the rest of the program.
- C. (http://symcbean.blogspot.c
November 4, 2008, 12:37 pm
Re: Checking port status using php
You're trying to solve the wrong problem in the wrong way here.
First, there are lots of existing tools for managing clusters (Ubuntu
Landscape springs to mind - but there are many, many more). Why write
If the problem is the length of time for the connection, then testing
the port before connecting is going to be just as expensive.
Why are you trying to do this in a single thread - a better solution
would be to start seperate threads of execution for each job and have
them report back to a central location. How do I run long-running
processes in PHP is a FAQ - try Google.
You also have to think about how you deal with errors - extending the
approach above, a better solution would be to use an asynchronous
message queue to despatch the jobs to servers.