Page 1 of 1
check network connection
Posted: Mon Aug 09, 2010 1:23 am
by Homesick
Hi guys ,,
I want to write on a file if the local server connection is down ,,
So,,I wanna ask if there a script to check the network connection of the local server,,
Re: check network connection
Posted: Mon Aug 09, 2010 2:01 am
by cpetercarter
I have seen a number of scripts where
fsockopen() is used to test whether a connection with a remote website could be established, and I guess that you could use it also for a connection to a local server.
Or you could simply use whatever script you use to write your file to the server, using the fact that fopen() returns 'false' if the file concerned cannot be opened (for whatever reason) :
Code: Select all
$h = @fopen($server_file, 'wb');
if (!$h) {
// write to the local machine instead
}