douya2982 2015-04-22 06:12
浏览 46

xStation:尝试通过PHP Socket客户端连接SSL服务器

I am having problem in establishing a SSL connection to remote server using PHP socket client.

Connecting to simple socket server is easy but SSL connection is keeping a live and doesn't respond anything, please look at the code below and guide me what mistake I am doing in the following code.

Page is keep loading but doesn't respond anything.

  1. // command array
  2. $command = array(
  3. 'command' => 'login',
  4. 'arguments' => array(
  5. 'userId' => 'xxxxxx',
  6. 'password' => 'xxxxxx',
  7. 'appId' => 'test',
  8. 'appName' => 'test',
  9. ),
  10. );
  11. $fp = stream_socket_client("ssl://xapia.x-station.eu:5124", $errno, $errstr, 30);
  12. if (!$fp) {
  13. die("Unable to connect: $errstr ($errno)");
  14. }
  15. /* Turn on encryption for login phase */
  16. fwrite($fp, json_encode($command));
  17. while ($motd = fgets($fp)) {
  18. echo $motd;
  19. echo '<hr />';
  20. }
  21. fclose($fp);
  • 写回答

0条回答 默认 最新

      编辑
      预览

      报告相同问题?

      手机看
      程序员都在用的中文IT技术交流社区

      程序员都在用的中文IT技术交流社区

      专业的中文 IT 技术社区,与千万技术人共成长

      专业的中文 IT 技术社区,与千万技术人共成长

      关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

      关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

      客服 返回
      顶部