php怎么实现这样的效果,大家来讨论下
php如何实现这样的效果,大家来讨论下。
检测是否能ping通201.168.56.17 。如果可以ping通。。echo (延迟是多少)
如果ping不通 》返回 echo("ping return ;")
就是检测对方主机是否运行。。。
大牛来指点一二。新手来学习一下。大家一起讨论下啦
------解决方案--------------------
搜到一段代码:
- PHP code
<?php $host = '192.168.1.1'; //要ping的地址,也可以是IP $port = '80'; //要ping的端口 $num = 3; function microtime_float() { list($usec, $sec) = explode(" ", microtime()); return ((float)$usec + (float)$sec); } function ping($host,$port) { $time_start = microtime_float(); $ip = gethostbyname($host); $fp = @fsockopen($host,$port,&$errno,&$errstr,1); if(!$fp) return 'replay time out!'; $get = "GET / HTTP/1.1\r\nHost: $host\r\nConnection: Close\r\n\r\n"; @fputs($fp,$get); @fclose($fp); $time_end = microtime_float(); $time = $time_end - $time_start; $time = ceil($time * 1000); return 'Reply from '.$ip.': time='.$time.'ms<br />'; } echo 'Pinging '.$host.' ['.gethostbyname($host).'] with Port:'.$port.' of data:<br><br>'."\r\n"; for($i = 0;$i <br><font color="#e78608">------解决方案--------------------</font><br>用 php 中的 exec() 调用命令来实现 最好。 <br><font color="#e78608">------解决方案--------------------</font><br>$ip = "192.168.1.1"; <br>exec( "ping $ip ", $arr); <br><br>print_r($arr); <br> <div class="clear"> </div>

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

Recently, many Win11 users have reported that when shutting down, they are prompted that the taskhostwindow task host is executing the shutdown task. So what is going on? Users can enter the Desktop folder under the local registry editor, and then select AutoEndTasks in the right window to set it. Let this site carefully introduce to users the solution to this problem when shutting down. Windows 11 shutdown prompts that the taskhostwindow task host is executing the shutdown task. Solution 1. Use the key combination win key + r key, enter "regedit" and press Enter, as shown in the figure below. 2. Search for [HKEY

When we launch Task Manager to terminate a task or stop an application, we usually find a large number of processes running. This is completely normal. However, sometimes we see programs that are using system resources that we are completely unaware of. One of these processes is the aggregator host.exe, which has been causing some confusion among users recently. Some of these processes may be legitimate Windows requirements, but others may be malicious programs running in the background and causing problems without the user's knowledge or consent. After we've seen the five ways you can launch Task Manager in Windows 11, we'll show you how to check if aggregator host.exe is safe or a virus. keep up

Xbox consoles have improved dramatically over the years. Over the years, games have evolved with life-like features that gamers can't seem to get enough of. Playing your favorite games on Xbox can be a completely engrossing experience. However, sometimes using these advanced features, we end up with lag or ping issues if the internet speed is not that good. Sometimes we want games to download faster. Today, games like Forza Horizon 5 and Mortal Kombat require over 100GB of RAM. Downloading such games can take a long time if we don't have the right internet settings to help us. Method 1: Pass

The solutions to "no route to host" include checking the network connection, checking the IP address and port, checking the firewall configuration, checking the routing configuration, checking the network device configuration, checking the network service status, checking the network configuration and contacting the network administrator. Detailed introduction: 1. Check the network connection to ensure that the network connection between the client and the target host is normal. You can try to test network connectivity through the ping command or other network tools, and check whether hardware devices such as network cables, wireless networks, and routers are working properly. Make sure the network connection is stable, etc.

The differences between master and host are: 1. Host can play the role of client or server, while master is the central server responsible for coordinating and managing other slave servers in a distributed system; 2. Host is an ordinary computer device, and master usually has Higher processing power and resources are used to process and distribute tasks, manage data, and maintain the stability of the entire system; 3. The host is a node in the network, and the master is the server that plays a core role in the distributed system.

The reasons for the ping request timeout include unreachable target host, network congestion, firewall or security settings, and DNS resolution issues. Detailed introduction: 1. The target host is unreachable. The Ping request timeout may mean that the target host cannot be accessed through the network. This may be due to the target host closing the network connection, the network where the target host is located failing, the target host IP address being set incorrectly, etc. ; 2. Network congestion. Ping request timeout may also be caused by network congestion. Network congestion may be due to large amounts of data transmission, network equipment failures, etc.

The network cannot ping, what's going on? In fact, this is a very common problem. It is mainly divided into two situations: pinging fails on the same network segment and pinging fails on different network segments. Let’s take a look at the details below. There are usually two reasons why the ping command cannot connect to the same network segment: one is an IP address that cannot be pinged in the same network segment, and the other is an IP address that cannot be pinged in a different network segment. These two situations have different solutions. First, let’s discuss the situation where ping fails within the same network segment. 1. Ping fails on the same network segment, and the result is "Unable to access the target host." The destination IP and source IP are on the same network segment, and the ping result is &l

The WMIProviderHost process plays a vital role in Windows 11. It enables other applications to request information about your computer. Processes related to WMIProviderHost typically run in the background; therefore, they typically do not consume large amounts of system resources. However, the service reportedly uses more than 50% of CPU power at times due to other applications. It is worrisome to run your computer's processor at nearly maximum capacity for an extended period of time, as this can lead to overheating and damage to system components. In today's tutorial, we will look at why WMIProviderHost works in C on Windows 11
