RE: [PHP-WIN] Check for a listening port...
| From: | Ross Fleming | Date: | Sun, 07 Jul 2002 17:52:08 +0000 |
| Subject: | RE: [PHP-WIN] Check for a listening port... | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-14579@lists.php.net to get a copy of this message | ||
Never mind, after an hour of scouring the manual I found out about sockets
and knocked this up:
<?php
$port = 8000;
$address = '127.0.0.1';
$socket = socket_create(AF_INET, SOCK_STREAM, 0);
$result = @socket_connect ($socket, $address, $port);
if ($result) {
header("location: http://localhost:8000/listen.pls");
} else {
echo "Server is down";
}
socket_close ($socket);
?>
-----Original Message-----
From: Ross Fleming [mailto:r.fleming@totalise.co.uk]
Sent: 07 July 2002 17:47
To: PHP Windows mailing list
Subject: [PHP-WIN] Check for a listening port...
Hi all
Short request: I'm looking for a php script that will test for a listening
port, (specifically port 8000 on the same server, say localhost). Basically
if port 8000 is active, I want to redirect to that, otherwise display a page
that says "service offline" or something.
Any ideas?
Cheers
Ross
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php