private function connect()
    {
        if ($this->socket) {
            return $this->socket;
        }

        shuffle($this->hosts);

        foreach ($this->hosts as $host) {
            list($ip, $port) = explode(':', $host);
            $this->socket = @fsockopen($ip, $port, $err_no, $err_str, 1);

            if ($this->socket) {
                break;
            }
        }

        if (!$this->socket) {
            throw new \RuntimeException('Unable to connect to the tracker.');
        }

        return $this->socket;
    }