Test if port open and forwarded using PHP
Full Disclosure: There's a similar question here . Is there any way I can test if a particular port is open and forwarded properly using PHP? Specifically, how do I go about using a socket to connect to a given user with a given port? An Example of this is in the 'Custom Port Test' section of WhatsMyIP.org/ports . I'm not sure what you mean by being "forwarded properly", but hopefully this example will do the trick: $host = 'stackoverflow.com'; $ports = array(21, 25, 80, 81, 110, 443, 3306); foreach ($ports as $port) { $connection = @fsockopen($host, $port); if (is_resource($connection)) {