php - How to find if a port is enabled on a webserver -
a noob question:
i want enable google cloud messaging on website being hosted on godaddy. want determine if port 5228 (to used gcm) enabled godaddy , if can go ahead , implement gcm.
how can find out? tried following code:
<?php $host = 'mysite.com'; $ports = array(5228, 5229, 5230); foreach ($ports $port) { $errno = null; $errstr = null; $connection = @fsockopen($host, $port, $errno, $errstr); if (is_resource($connection)) { echo '<h2>' . $host . ':' . $port . ' ' . '(' . getservbyport($port, 'tcp') . ') open.</h2>' . "\n"; fclose($connection); } else { echo "<h2>{$host}:{$port} not responding. error {$errno}: {$errstr} </h2>" . "\n"; }
} ?>
i got following result:
mysite.com:5228 not responding. error 111: connection refused mysite.com:5229 not responding. error 111: connection refused mysite.com:5230 not responding. error 111: connection refused
does mean godaddy not allow me implement gcm 5228 not enabled? or mean firewall(or isp) not letting me connect tehe website @ port 5228?
thanks
p.s.: know there many questions regarding topic, did surf them not able definitive answer.
ports 5228, 5229, 5230 needed android devices, not server going push notifications gcm.
if want check if server connect gcm, try create post http request gcm: https://android.googleapis.com/gcm/send
btw code trying connect mysite.com, not gcm
Comments
Post a Comment