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:
Daniele Alessandri
2013-02-16 11:03:28 +01:00
parent c38376dcc4
commit 8d01be388d
4 changed files with 45 additions and 0 deletions
@@ -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;
}