Test eğer port açık ve iletilen PHP kullanarak

1 Cevap php

Tam Açıklama: Benzer bir soru var here.

Belirli bir liman açık ve PHP kullanarak düzgün iletilmesini ben test edebilirsiniz herhangi bir yolu var mı? Özellikle, nasıl belirli bir bağlantı noktası ile belirli bir kullanıcıya bağlanmak için bir soket kullanan gidiyorsun?

Bunun bir örneği WhatsMyIP.org/ports in 'Özel Port Test' bölümünde.

1 Cevap

Sana "düzgün iletilmesini" ediliyor, ama umarım bu örnek hile yapacak ile ne demek emin değilim:

$host = 'stackoverflow.com';
$ports = array(21, 25, 80, 81, 110, 443, 3306);

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";
    }
}

Çıktı:

stackoverflow.com:21 is not responding.
stackoverflow.com:25 is not responding.
stackoverflow.com:80 (http) is open.
stackoverflow.com:81 is not responding.
stackoverflow.com:110 is not responding.
stackoverflow.com:443 is not responding.
stackoverflow.com:3306 is not responding.

See http://www.iana.org/assignments/port-numbers port numaralarının tam listesi için.