note 78495 deleted from function.fsockopen by danbrown

From: Date: Sun, 20 Jul 2008 19:24:19 +0000
Subject: note 78495 deleted from function.fsockopen by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-142293@lists.php.net to get a copy of this message
Note Submitter: parming at gmail dot com ---- A pretty crude, but somewhat useful force-ping of the nearest network may come in handy for other mediocre coders like me. It returns an array of all replying boxes according to your $port choice (where, for reference, 139 targets all network cards and 3306 only running mysql apps). Keep the $timeout under 1 and the function can run in-under a second. Obvious limitations apply. $ip = implode(".", array_slice(explode(".", $_SERVER["SERVER_ADDR"]), 0, 3)) . "."; for ($i =0; $i < 255; $i++) if (@fsockopen($ip . $i, $port, $err, $errstr, $timeout)) $online[] = $ip . $i; The function can be expanded with additional for-loops, but I can't see the direct purpose of pinging everything-there-is. Daniel Parming

« previous php.notes (#142293) next »