Swoole\Coroutine\Client->exportSocket()

4.x is outdated, please check the latest version 22.x


Latest version: pecl install openswoole-22.1.2

Declaration

<?php Swoole\Coroutine\Client->exportSocket()

Parameters

None

Return

Returns the underlying socket connection object that is being used within the client.

Description

Export the underlying socket connection object that is being used within the client, this allows you to use the socket with PHP native functions.

You must have installed Swoole using --enable-sockets for this to work.

Example

<?php

$socket = $client->exportSocket();

if(!socket_set_option($socket, SOL_SOCKET, SO_REUSEADDR, 1))
{
  echo 'Unable to set option on socket: '. socket_strerror(socket_last_error()) . PHP_EOL;
}
else
{
  echo "Option set on socket\n";
}
Last updated on August 31, 2022