OpenSwoole\Coroutine\Client->exportSocket()

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

Declaration

<?php OpenSwoole\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 OpenSwoole 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 September 1, 2022