Home > php教程 > PHP源码 > body text

在线端口扫描工具

PHP中文网
Release: 2016-05-23 17:10:16
Original
4426 people have browsed it

1. [代码]在线端口扫描工具(http://www.atool.org/port_scanner.php

端口扫描器可以用于检查VPS服务器端口是否开放,对于网站和服务器的安全非常重要。

class Health {
	public static $status;
	public function __construct() {
	}
	public function check($ip, $port, $timeout = 2){
		$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
		socket_set_nonblock($sock);
		socket_connect($sock,$ip, $port);
		socket_set_block($sock);
		self::$status = socket_select($r = array($sock), $w = array($sock), $f = array($sock), 2);
		return(self::$status); 
	}
	public function status(){
		switch(self::$status)
		{
			case 2:
				return "Closed";
				break;
			case 1:
				return "Openning";
				break;
			case 0:
				return "Closed";
				break;
		}	
	}
}
Copy after login

2. [图片] _E6_9C_AA_E5_91_BD_E5_90_8D.png          

在线端口扫描工具

                                           

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!