mirror of
https://github.com/predis/predis.git
synced 2026-08-21 05:44:53 +00:00
Do not use different methods to initialize socket for the PhpiredisConnection.
This commit is contained in:
@@ -172,47 +172,20 @@ class PhpiredisConnection extends ConnectionBase
|
||||
{
|
||||
$parameters = $this->parameters;
|
||||
|
||||
$initializer = array($this, "{$parameters->scheme}SocketInitializer");
|
||||
$socket = call_user_func($initializer, $parameters);
|
||||
$isUnix = $this->parameters->scheme === 'unix';
|
||||
$domain = $isUnix ? AF_UNIX : AF_INET;
|
||||
$protocol = $isUnix ? 0 : SOL_TCP;
|
||||
|
||||
$socket = @call_user_func('socket_create', $domain, SOCK_STREAM, $protocol);
|
||||
if (!is_resource($socket)) {
|
||||
$this->emitSocketError();
|
||||
}
|
||||
|
||||
$this->setSocketOptions($socket, $parameters);
|
||||
|
||||
return $socket;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes a TCP socket resource.
|
||||
*
|
||||
* @param IConnectionParameters $parameters Parameters used to initialize the connection.
|
||||
* @return resource
|
||||
*/
|
||||
private function tcpSocketInitializer(IConnectionParameters $parameters)
|
||||
{
|
||||
$socket = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
|
||||
if (!is_resource($socket)) {
|
||||
$this->emitSocketError();
|
||||
}
|
||||
|
||||
return $socket;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes a UNIX socket resource.
|
||||
*
|
||||
* @param IConnectionParameters $parameters Parameters used to initialize the connection.
|
||||
* @return resource
|
||||
*/
|
||||
private function unixSocketInitializer(IConnectionParameters $parameters)
|
||||
{
|
||||
$socket = @socket_create(AF_UNIX, SOCK_STREAM, 0);
|
||||
|
||||
if (!is_resource($socket)) {
|
||||
$this->emitSocketError();
|
||||
}
|
||||
|
||||
return $socket;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets options on the socket resource from the connection parameters.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user