Swoole\Coroutine\Client->exportSocket()

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";
}