library/Rediska/Connection/Socket.php
protected function _createSocketConnection()
    {
        $socket = socket_create(AF_INET, SOCK_STREAM, getprotobyname('tcp'));

        socket_set_option($socket, SOL_SOCKET, TCP_NODELAY, 1);

        @socket_set_nonblock($socket);
        $result = @socket_connect($socket, $this->getHost(), $this->getPort());

        if ($result === false) {
            $errorCode = socket_last_error($socket);
            if ($errorCode !== SOCKET_EINPROGRESS) {
                return null;
            }
        }else{
            //@socket_set_block($socket);

            return $socket;
        }

        /* Do whatever we want while the connect is taking place. */
        $result = @socket_select($r = array($socket), $w = array($socket), $e = array($socket), $this->getTimeout());

        if ($result === 0 || $result === false) {
            return null;
        }

        if (!(($r && count($r)) || ($w && count($w))) || @socket_get_option($socket, SOL_SOCKET, SO_ERROR) != 0) {
            return null;
        }

        //@socket_set_block($socket);

        return $socket;
    }
protected function _createSocketConnection()
    {
        $socket = socket_create(AF_INET, SOCK_STREAM, getprotobyname('tcp'));

        socket_set_option($socket, SOL_SOCKET, TCP_NODELAY, 1);

        @socket_set_nonblock($socket);
        $result = @socket_connect($socket, $this->getHost(), $this->getPort());

        if ($result === false) {
            $errorCode = socket_last_error($socket);
            if ($errorCode !== SOCKET_EINPROGRESS) {
                return null;
            }
        }else{
            //@socket_set_block($socket);

            return $socket;
        }

        /* Do whatever we want while the connect is taking place. */
        $result = @socket_select($r = array($socket), $w = array($socket), $e = array($socket), $this->getTimeout());

        if ($result === 0 || $result === false) {
            return null;
        }

        if (!(($r && count($r)) || ($w && count($w))) || @socket_get_option($socket, SOL_SOCKET, SO_ERROR) != 0) {
            return null;
        }

        //@socket_set_block($socket);

        return $socket;
    }
Create socket connection

@return null|resource