


PHP code to determine whether the server port is open_PHP tutorial
Record it for future reference
<ol class="dp-xml"> <li class="alt"><span><span class="tag"><?</span><span class="tag-name">php</span><span> </span></span></li><li><span>$</span><span class="attribute">host</span><span> = </span><span class="attribute-value">www.google.com</span><span>; //要ping的地址,也可以是IP </span></li><li class="alt"><span>$</span><span class="attribute">port</span><span> = </span><span class="attribute-value">80</span><span>; //要ping的端口 </span></li><li><span>$</span><span class="attribute">num</span><span> = </span><span class="attribute-value">3</span><span>; </span></li><li class="alt"><span>function microtime_float() </span></li><li><span>{ </span></li><li class="alt"><span>list($usec, $sec) = explode(" ", microtime()); </span></li><li><span>return ((float)$usec + (float)$sec); </span></li><li class="alt"><span>} </span></li><li><span>function ping($host,$port) </span></li><li class="alt"><span>{ </span></li><li><span>$</span><span class="attribute">time_start</span><span> = </span><span class="attribute-value">microtime_float</span><span>(); </span></li><li class="alt"><span>$</span><span class="attribute">ip</span><span> = </span><span class="attribute-value">gethostbyname</span><span>($host); </span></li><li><span>$</span><span class="attribute">fp</span><span> = @fsockopen($host,$port,&$errno,&$errstr,1); </span></li><li class="alt"><span>if(!$fp) return replay time out!; </span></li><li><span>$</span><span class="attribute">get</span><span> = </span><span class="attribute-value">"GET / HTTP/1.1 Host:"</span><span>.$host." Connection: Close "; </span></li><li class="alt"><span>@fputs($fp,$get); </span></li><li><span>@fclose($fp); </span></li><li class="alt"><span>$</span><span class="attribute">time_end</span><span> = </span><span class="attribute-value">microtime_float</span><span>(); </span></li><li><span>$</span><span class="attribute">time</span><span> = $time_end - $time_start; </span></li><li class="alt"><span>$</span><span class="attribute">time</span><span> = </span><span class="attribute-value">ceil</span><span>($time * 1000); </span></li><li><span>return Reply from .$ip.: </span><span class="attribute">time</span><span>=.$time.</span><span class="attribute-value">ms</span><span class="tag"><</span><span class="tag-name">br</span><span> </span><span class="tag">/></span><span>; </span></span></li> <li class="alt"><span>} </span></li> <li> <span>echo Pinging .$host. [.gethostbyname($host).] with Port:.$port. of data:</span><span class="tag"><</span><span class="tag-name">br</span><span> </span><span class="tag">/></span><span class="tag"><</span><span class="tag-name">br</span><span> </span><span class="tag">/></span><span>." "; </span> </li> <li class="alt"> <span>for($</span><span class="attribute">i</span><span> = </span><span class="attribute-value">0</span><span>;$i </span><span class="tag"><</span><span> $num;$i++) </span></li><li><span>{ </span></li><li class="alt"><span>ping($host,$port); </span></li><li><span>sleep(1); </span></li><li class="alt"><span>ob_flush(); </span></li><li><span>flush(); </span></li><li class="alt"><span>} </span></li><li><span class="tag">?></span><span> </span> </li> </ol>
This article is excerpted from http://www.cnblogs.com/luoine/archive/2010/12/01/1893156.html

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

Working with database in CakePHP is very easy. We will understand the CRUD (Create, Read, Update, Delete) operations in this chapter.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

In this chapter, we are going to learn the following topics related to routing ?

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Validator can be created by adding the following two lines in the controller.
