protected function _ensureSocketCreated() {
        // Already ready!
        if (is_resource($this->socket_)) {
            return TRUE;
        }

        $sockaddr = $this->scheme_ . '://' . $this->host_;
        $port = $this->port_;

        // Ignore the Thrift specified timeout ($this->timeout_) and use the
        // socket-specific timeout set in this file.
        $timeout = self::DEFAULT_CONNECT_TIMEOUT_SECS;

        for ($retry = 0; $retry < self::MAX_SOCKET_OPEN_RETRIES; $retry++) {
            try {
                // Suppress connection error logs
                $fd = @pfsockopen($sockaddr, $port, $errno, $errstr, $timeout);
                if ($errno == 0 && is_resource($fd)) {
                    // Connection okay - break out of the retry loop
                    stream_set_blocking($fd, 0);
                    stream_set_timeout($fd, 0, self::DEFAULT_STREAM_TIMEOUT_MICROS);
                    $this->socket_ = $fd;
                    break;
                }
            } catch (Exception $e) {
                // Ignore the exception and retry
            }
        }

        return is_resource($this->socket_);
    }