"Fossies" - the Fresh Open Source Software Archive

Member "node-runner-0.6.0/include/query_tcp.php" (20 Oct 2004, 923 Bytes) of package /linux/www/old/node-runner-0.6.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "query_tcp.php" see the Fossies "Dox" file reference documentation.

    1 <?php
    2 
    3 // This is an example script that queries raw TCP sockets.
    4 
    5 array_push($queries_type_array, "TCP");
    6 
    7 function tcp_query($description, $ipaddress, $port, $ptime) {
    8   global $debug,$allow_refused;
    9   
   10   $status = array();
   11 
   12   $socket = fsockopen($ipaddress, $port, $errno, $errstr, $ptime);
   13 
   14   if (($allow_refused == 1) && ($errno == 111)) {
   15     $status[0] = 1;
   16     $status[1] = $description." UP";
   17     if ($debug == 1) { $status[1] .= " - TCP Port ".$port." Responded \"refused\", but that's acceptable enough."; }
   18   } else if (!$socket) {
   19     $status[0] = 0;
   20     $status[1] = $description." DOWN";
   21     if ($debug == 1) { $status[1] .= " - TCP Error ".$errno.": ".$errstr; }
   22   } else {
   23     $status[0] = 1;
   24     $status[1] = $description." UP";
   25     if ($debug == 1) { $status[1] .= " - TCP Port ".$port." Responded Correctly."; }
   26   }
   27   
   28   if ($socket) { fclose($socket); }
   29 
   30   $status[1] .= "\n";
   31   return $status;
   32 
   33 }
   34 
   35 ?>