fsocketopen error

hey guys

How would I get rid of this error:

I guess I’ll paste the output because maybe its something with the way I have my machine set up. I’ve got apache 2.2, php 5, winxp

SCANman Scanner test v0.1

Now scanning IP address 192.168.2.2

Warning: fsockopen() [function.fsockopen]: unable to connect to 192.168.2.2:2 (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ) in C:Documents and SettingsJeffreyDesktopPHPSimpleScan.class.php on line 79
2, A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. (10060), 3.01s

I’ll post the code too

<?PHP /* * Simple Scan class (c) 2003 Michal Cumpl * * Description: Simple scanner class * * * Constructor * * SimpleScan(" correct IP address "," connection time out in s") * * * Functions * * portInfo(" port number ") * - scan given port and store results in object variables * * mtime() * - return current timestamp with microseconds * * Variables * * $ip ... Scanned IP adderess * $port ... currently scanned port * $timeout ... port connection timeout * $numports ... number of scanned ports * $openports ... number of open ports * $portstatus ... current port status (true/false) * $portresponse ... current port info (errorstring or fgets output) * $starttime ... start timestamp * $actualtime ... current port scanning time * $totaltime ... total time of scanning in s * * * Example usage * * $scan = new SimpleScan("127.0.0.1", 0.2); * echo "Now scanning IP address ".$scan->ip."
"; * for($i= ; $i<=80 ; $i++) * { * $scan->portinfo($i); * echo $scan->port.", ".$scan->portresponse.", ".round($scan->actualtime,2)."s
"; * } * echo "Number of scanned ports: ".$scan->numports."
"; * echo "Number of open ports: ".$scan->openports."
"; * echo "Total time: ".round($scan->totlatime,2)."
"; */ class SimpleScan { var $ip; var $port; var $timeout; var $numports; var $openports; var $portstatus; var $portresponse; var $starttime; var $actualtime; var $totaltime; function simpleScan($ip,$timeout) { $this->ip = $ip; if($timeout > 0.01 && $timeout < 10) $this->timeout = $timeout; else $this->timeout = 0.5; $this->numports = 0; $this->openports = 0; $this->starttime = $this->mtime(); $this->actualtime = 0; $this->totaltime = 0; } function portInfo($port) { flush(); $this->port = $port; $time = $this->mtime(); $fp = fsockopen ("$this->ip", $this->port, $errno, $errstr, $this->timeout); if(!$fp) { $this->portstatus = false; $this->portresponse = $errstr." (".$errno.")"; } else { if($this->port == 80) { fputs ($fp, "GET / HTTP/1.0rnHost: ".$this->ip."rnrn"); for($i=0;$i<5;$i++) { $tmpresponse = fgets($fp,1024); if(ereg("Server",$tmpresponse)) $this->portresponse = $tmpresponse; } } else { $this->portresponse = fgets($fp,1024); } $this->portstatus = true; $this->openports++; fclose($fp); } $this->actualtime = $this->mtime() - $time; $this->totaltime = $this->mtime() - $this->starttime; $this->numports++; } function mtime() { list($usec, $sec) = explode(" ",microtime()); return ((float)$usec + (float)$sec); } } $v_ip = $REMOTE_ADDR; $host = $_REQUEST['host']; $start = $_REQUEST['start']; $end = $_REQUEST['end']; $scan = new SimpleScan($host, 3); echo "SCANman Scanner test v0.1

"; echo "Now scanning IP address ".$scan->ip."
".$v_ip; for($start; $start <= $end ; $start++) { $scan->portinfo($start); echo $scan->port.", ".$scan->portresponse.", ".round($scan->actualtime,2)."s
"; } echo "Number of scanned ports: ".$scan->numports."
"; echo "Number of open ports: ".$scan->openports."
"; echo "Total time: ".round($scan->totlatime,2)."
"; ?>

$fp = @fsockopen ("$this->ip", $this->port, $errno, $errstr, $this->timeout);

http://php.net/operators.errorcontrol

Sponsor our Newsletter | Privacy Policy | Terms of Service