Join 4,000+ others and never miss out on new tips, tutorials, and more.
Latest version:
pecl install openswoole-22.1.2 | composer require openswoole/core:22.1.5
<?php OpenSwoole\WebSocket\Server->getClientInfo(int $fd): bool|array
The fd of the WebSocket connection
If success, it returns , otherwise it returns false
Get the TCP connection info.
An array is returned if the $fd
is correct.
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 handshakeWEBSOCKET_STATUS_HANDSHAKE
= 2, in the process of WebSocket handshake validationWEBSOCKET_STATUS_ACTIVE
= 3 (renamed from WEBSOCKET_STATUS_FRAME
), handshake finished and waiting for transforming/browser messageWEBSOCKET_STATUS_CLOSING
= 4, the connection is undergoing a closing handshake and will be closed soon