我有一些创建 SSL 连接的简单 PHP 代码
$streamContext = stream_context_create();
stream_context_set_option($streamContext, 'ssl', 'local_cert', $this->sslPem);
stream_context_set_option($streamContext, 'ssl', 'passphrase', $this->passPhrase);
$this->apnsConnection = stream_socket_client('ssl://'.$this->apnsHost.':'.$this->apnsPort, $error, $errorString, 60, STREAM_CLIENT_CONNECT, $streamContext);
但是知道如何将 SO_KEEPALIVE 设置为 true 吗?我也试过 STREAM_CLIENT_PERSISTENT,这不是一回事。
最佳答案
您是否已确认(通过网络跟踪)您需要设置套接字选项?
您要通过套接字发送什么? HTTP/HTTPS 通过“连接” header 引入了自己的连接重用功能,因此套接字上的选项不一定是您想要设置的。
关于php - 如何使用 SO_KEEPALIVE 在 PHP 中创建 SSL 连接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1116450/