transport özelliği

gereksinim (workerman >= 3.3.4)

Taşıma özelliğini ayarlayın, seçilebilir değerler tcp ve ssl olup, varsayılan değeri tcp'dir.

transport ssl olduğunda, PHP'nin openssl uzantısını kurulu olması gerekmektedir.

Workerman'ı bir istemci olarak sunucuya ssl şifreli bağlantı (https bağlantısı, wss bağlantısı vb.) kurmak için bu seçeneği ssl olarak ayarlayın, örneğin aşağıdaki örnekte olduğu gibi.

Örnek (https bağlantısı)

use Workerman\Worker;
use Workerman\Connection\AsyncTcpConnection;
use Workerman\Connection\TcpConnection;
require_once __DIR__ . '/vendor/autoload.php';

$task = new Worker();
// Süreç başlatıldığında www.baidu.com'a asenkron bir bağlantı nesnesi oluştur ve veri gönderip alın
$task->onWorkerStart = function($task)
{
    $connection_to_baidu = new AsyncTcpConnection('tcp://www.baidu.com:443');

    // ssl şifreli bağlantı olarak ayarla
    $connection_to_baidu->transport = 'ssl';

    $connection_to_baidu->onConnect = function(AsyncTcpConnection $connection_to_baidu)
    {
        echo "bağlantı başarılı\n";
        $connection_to_baidu->send("GET / HTTP/1.1\r\nHost: www.baidu.com\r\nConnection: keep-alive\r\n\r\n");
    };
    $connection_to_baidu->onMessage = function(AsyncTcpConnection $connection_to_baidu, $http_buffer)
    {
        echo $http_buffer;
    };
    $connection_to_baidu->onClose = function(AsyncTcpConnection $connection_to_baidu)
    {
        echo "bağlantı kapatıldı\n";
    };
    $connection_to_baidu->onError = function(AsyncTcpConnection $connection_to_baidu, $code, $msg)
    {
        echo "Hata kodu:$code mesaj:$msg\n";
    };
    $connection_to_baidu->connect();
};

// işçi çalıştır
Worker::runAll();