Swoole TCP/UDP client properties

Table of Content

  • Swoole\Client->errCode
  • Swoole\Client->sock
  • Swoole\Client->reuse


Alias: swoole_client->errCode

When the call of method connect/send/recv/close failed, the value of swoole_client->errCode is setted automatically.

The value of swoole_client->errCode equals to the value of errno of Linux. You can use socket_strerror to check the concrete information of errCode.

echo socket_strerror($client->errCode);


Alias: swoole_client->sock

It is an integer which stands for the file descriptor of socket.

You can use this value to convert a stream socket used for fread/fwrite/fclose functions.

$sock = fopen("php://fd/".$swoole_client->sock); 


Alias: swoole_client->reuse

It is an Boolean value which stands for reuse status of socket.

if ($client->reuse)
    // reused socket
    // new socket