BjornR_1989 Posted December 10, 2008 Share Posted December 10, 2008 As i'm using PHP to detirmine which services are running at wich server in my network i need to look for open (active) ports. This script should work: function upstr($server, $port, $timeout){ if(!fsockopen($server, $port, $errno, $errstr, $timeout){ return false; }else{ return true; } } ... but it doesn't. According to that script, all ports on all servers are open. That's partially true, there is no firewall on the servers so all ports are wide open but there's no service running on them. And even if i enable the firewalls the script keeps returning 'true' because the listening ports stay open. So how can i really rely on PHP to check this? I implemented a script that sends an end-of-line char to the port and evaluates its response but port 80 (Apache HTTP server) doesn't answer, even if it is running & available to clients. fwrite($fp, "\n"); $response = fread($fp, 26); fclose($fp); I'm running Apache 2.0.55 / PHP 5.2.1 on Windows. Link to comment https://forums.phpfreaks.com/topic/136330-php-portscanner/ Share on other sites More sharing options...
BjornR_1989 Posted December 10, 2008 Author Share Posted December 10, 2008 *bump* Since i can't edit my first post: I'm aware of the typo in the first code. The correct code was: function upstr($server, $port, $timeout){ if(!fsockopen($server, $port, $errno, $errstr, $timeout)){ return false; }else{ return true; } } ... And it still doesn't work. Link to comment https://forums.phpfreaks.com/topic/136330-php-portscanner/#findComment-711420 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.