OpenSwoole\WebSocket\Server->getClientInfo

Latest version: pecl install openswoole-22.1.2 | composer require openswoole/core:22.1.5

Declaration

<?php OpenSwoole\WebSocket\Server->getClientInfo(int $fd): bool|array

Parameters

fd

The fd of the WebSocket connection

Return

If success, it returns , otherwise it returns false

Description

Get the TCP connection info.

An array is returned if the $fd is correct.

Get WebSocket Connection Status

You can get the WebSocket connection status (constants) from websocket_status with function $server->getClientInfo($fd):

  • WEBSOCKET_STATUS_CONNECTION = 1, connection created and wait for handshake
  • WEBSOCKET_STATUS_HANDSHAKE = 2, in the process of WebSocket handshake validation
  • WEBSOCKET_STATUS_ACTIVE = 3 (renamed from WEBSOCKET_STATUS_FRAME), handshake finished and waiting for transforming/browser message
  • WEBSOCKET_STATUS_CLOSING = 4, the connection is undergoing a closing handshake and will be closed soon
Last updated on September 1, 2022