本文介绍了侦测IP与端口,没有返回值,PHP / APACHE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用下面获得的状态和IP或域名

I'm using the following to get status of and IP or a domain

<?php
 system('ping -c1 -w1 193.33.186.70') ;
?>

如何将我平80端口寿?返回什么都没有,一旦端口提供..试图将它添加到年底'80'和'80'

How would I ping port 80 tho? Returns nothing at all once port is supplied.. tried to add it to the end by ':80' and ' 80'

任何想法AP preaciated!

Any ideas appreaciated!

推荐答案

如果你想要做的是找出给定主机是否接受端口80上的TCP连接,你可以这样做:

If what you want to do is find out whether a given host will accept TCP connections on port 80, you can do this:

$host = '193.33.186.70';
$port = 80;
$waitTimeoutInSeconds = 1;
if ($fp = fsockopen($host,$port,$errCode,$errStr,$waitTimeoutInSeconds)) {
  // It worked
} else {
  // It didn't work
}
fclose($fp);

有关比TCP这将是更困难(虽然因为你指定80,我猜你正在寻找一个活跃的HTTP服务器,因此TCP是你想要的)以外的任何其他。 TCP测序和确认,所以你会隐含收到一个数据包返回时,成功建立连接。大多数其它传输协议(UDP常见,但其他人也)不会以这种方式行事,而除非叠加应用层协议实现它的数据包不会被承认。

For anything other than TCP it will be more difficult (although since you specify 80, I guess you are looking for an active HTTP server, so TCP is what you want). TCP is sequenced and acknowledged, so you will implicitly receive a returned packet when a connection is successfully made. Most other transport protocols (commonly UDP, but others as well) do not behave in this manner, and datagrams will not be acknowledged unless the overlayed Application Layer protocol implements it.

这是你问这种方式这个问题的事实告诉我,你有你的知识基础上的差距协议。你应该在并的,还有 OSI模型

The fact that you are asking this question in this manner tells me you have a fundamental gap in your knowledge on Transport Layer protocols. You should read up on ICMP and TCP, as well as the OSI Model.

这篇关于侦测IP与端口,没有返回值,PHP / APACHE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!