Join 4,000+ others and never miss out on new tips, tutorials, and more.
4.x is outdated, please check the latest version 22.x
Latest version:
pecl install openswoole-22.1.2
<?php Swoole\Coroutine\Client->exportSocket()
None
Returns the underlying socket connection object that is being used within the client.
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.
<?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";
}