【发布时间】:2014-02-24 07:33:06
【问题描述】:
我正在尝试检查我的服务器上的端口是否打开,我有一些 php 可以做到这一点
<?php
$host = 'xxxxxxxxxxxxxxxxxxx';
$ports = array(xxxxxx);
foreach ($ports as $port)
{
$connection = @fsockopen($host, $port);
if (is_resource($connection))
{
echo '<h2>' . $host . ':' . $port . ' ' . '(' . getservbyport($port, 'tcp') . ') is open.</h2>' . "\n";
fclose($connection);
}
else
{
echo '<h2>' . $host . ':' . $port . ' is not responding.</h2>' . "\n";
}
}
?>
输出如下:
domain.zapto.org:80 (http) 已打开。 domain.zapto.org:8090 不是。 回应。 domain.zapto.org:34134 没有响应。
但是如果我去 domain.zapto.org:34134 它工作正常....所以它是可以访问的,但为什么它说它不是?有任何想法吗?谢谢各位。
【问题讨论】:
标签: php connection ports