PHP客户端Websockets与SSL加密异步

时间:2013-05-28 11:30:27

标签: php phpwebsocket

请指导我使用SSL加密+异步的客户端和服务器websocket连接。

让我知道有没有办法在PHP中执行此操作?

提前致谢。

:help :: help:

嗨,对于支持,我做了以下代码规范,但有些根据要求不能正常工作。

套接字客户端连接:

<?php

//Details of server websocket SSL encypted 
$ip="111.111.0.111";               //Set the TCP IP Address to connect too
$port="7109";                  //Set the TCP PORT to connect too

#Connect to Server
$socket = stream_socket_client("tcp://{$ip}:{$port}", $errno, $errstr, 30,STREAM_CLIENT_CONNECT | STREAM_CLIENT_ASYNC_CONNECT);

if($socket) {
   #Start SSL
   stream_set_blocking ($socket, true);
   stream_socket_enable_crypto ($socket, true, STREAM_CRYPTO_METHOD_SSLv23_CLIENT);   
   stream_set_blocking ($socket, false);

   $buf = null;
   #Receive response from server. Loop until the response is finished
   while (!feof($socket)) {
      $buf .= fread($socket, 4);
   }

   #echo our command response
   echo $buf;

   #close connection
   fclose($socket);
}
?>

我在stream_socket_client函数中使用STREAM_CLIENT_CONNECT | STREAM_CLIENT_ASYNC_CONNECT选项。错误如下:

Warning: stream_socket_enable_crypto() [function.stream-socket-enable-crypto]: 
SSL: The operation completed successfully.

0 个答案:

没有答案