如何查找web服务器上是否启用了端口


How to find if a port is enabled on a webserver

一个新手问题:

我想启用谷歌云消息在我的网站被托管在godaddy。我想确定端口5228(由GCM使用)是否被godaddy启用,以及我是否可以继续实现GCM。

我怎样才能找到它?我尝试了以下代码:

<?php
    $host = 'mysite.com';
    $ports = array(5228, 5229, 5230);    
foreach ($ports as $port)
{
$errno  = null;
$errstr = null;
$connection = @fsockopen($host, $port, $errno, $errstr);
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. Error {$errno}: {$errstr} </h2>" . "'n";
}

}?>

我得到了以下结果:

mysite.com:5228 is not responding. Error 111: Connection refused
mysite.com:5229 is not responding. Error 111: Connection refused
mysite.com:5230 is not responding. Error 111: Connection refused

这是否意味着goDaddy将不允许我实现GCM,因为5228没有启用?或者这是否意味着我的防火墙(或ISP)不允许我连接到端口5228的网站?

感谢

注。:我知道关于这个话题有很多问题,我确实浏览了一下,但是没有得到一个明确的答案。

端口5228,5229,5230是android设备需要的,而不是要向GCM推送通知的服务器需要的。

如果你想检查你的服务器是否连接到GCM,尝试创建一个POST HTTP请求到GCM: https://android.googleapis.com/gcm/send

顺便说一句,你的代码正试图连接到mysite.com,而不是GCM