예제 #1
0
파일: TCP.php 프로젝트: pengzhile/purl
 protected function newClient()
 {
     $flag = STREAM_CLIENT_ASYNC_CONNECT | STREAM_CLIENT_CONNECT;
     $remote = 'tcp://' . $this->ip . ':' . $this->port;
     $fp = stream_socket_client($remote, $errNo, $errStr, 0, $flag);
     Helper::assert(false !== $fp, 'Unable to init stream, code: ' . $errNo);
     return $fp;
 }
예제 #2
0
파일: SSL.php 프로젝트: pengzhile/purl
 protected function newClient()
 {
     $flag = STREAM_CLIENT_ASYNC_CONNECT | STREAM_CLIENT_CONNECT;
     $remote = 'tls://' . $this->ip . ':' . $this->port;
     $options = array('ssl' => array('peer_name' => $this->host, 'disable_compression' => true, 'SNI_enabled' => true, 'cafile' => __DIR__ . '/cacert.pem', 'verify_depth' => 7, 'verify_peer' => $this->verifyCert, 'verify_peer_name' => $this->verifyCert, 'allow_self_signed' => !$this->verifyCert));
     if (PHP_VERSION_ID < 50600) {
         $options['ssl']['CN_match'] = $this->host;
         $options['ssl']['SNI_server_name'] = $this->host;
     }
     $context = stream_context_create($options);
     $fp = stream_socket_client($remote, $errNo, $errStr, $this->connTimeout / 1000000, $flag, $context);
     Helper::assert(false !== $fp, 'Unable to init stream, code: ' . $errNo);
     return $fp;
 }