mirror of
https://github.com/predis/predis.git
synced 2026-08-28 11:09:49 +00:00
Support TCP_NODELAY for stream-based connections on PHP >= 5.4.0.
This cannot be implemented for previous versions of PHP because we need socket_import_stream() to extract the underlying socket resource from the stream in order to be able to set the TCP_NODELAY flag.
This commit is contained in:
@@ -101,6 +101,11 @@ class StreamConnection extends AbstractConnection
|
||||
stream_set_timeout($resource, $timeoutSeconds, $timeoutUSeconds);
|
||||
}
|
||||
|
||||
if (isset($parameters->tcp_nodelay) && version_compare(PHP_VERSION, '5.4.0', '>=')) {
|
||||
$socket = socket_import_stream($resource);
|
||||
socket_set_option($socket, SOL_TCP, TCP_NODELAY, (int) $parameters->tcp_nodelay);
|
||||
}
|
||||
|
||||
return $resource;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user