diff --git a/src/TcpConnector.php b/src/TcpConnector.php index 0949184..6a48d49 100644 --- a/src/TcpConnector.php +++ b/src/TcpConnector.php @@ -82,6 +82,16 @@ public function connect($uri) )); } + // Support socket_set_option($socket, SOL_SOCKET, $option, $value) + // Sets socket options for the socket: https://www.php.net/manual/en/function.socket-set-option.php + if (isset($context['socket']['socket_options']) && \function_exists('socket_import_stream')) { + $socket = \socket_import_stream($stream); + foreach ($context['socket']['socket_options'] as $option => $value) { + \socket_set_option($socket, \SOL_SOCKET, $option, $value); + } + $stream = \socket_export_stream($socket); + } + // wait for connection return new Promise(function ($resolve, $reject) use ($stream, $uri) { $this->loop->addWriteStream($stream, function ($stream) use ($resolve, $reject, $uri) {