libjingle を使用してコードを書いていますが、最初のステップである XMPP サーバーへのログオンに問題があります。私のコードは、goog のサンプル コードと pcp サンプル コードに基づいています。このコードは 1 つのスレッドしか実行していないように見えるため、少し混乱します。これは非常に基本的な質問であることがわかります。
とにかく、ここに私のコードの肉とジャガイモがあります:
    talk_base::PhysicalSocketServer ss;
    talk_base::AutoThread main_thread(&ss);
    buzz::Jid jid( xmppUsername + "@" + xmppHost );
    if (!jid.IsValid() || jid.node() == "")
        throw "Invalid JID. JIDs should be in the form user@domain" ;
    buzz::TlsOptions tls = buzz::TLS_ENABLED;
    buzz::XmppClientSettings xcs;
    xcs.set_user(jid.node());
    xcs.set_host(jid.domain());
    xcs.set_resource("pcp");
    xcs.set_pass(talk_base::CryptString(pass));
    xcs.set_allow_plain(true);
    xcs.set_server(talk_base::SocketAddress(xmppHost.c_str(), 5222));
    xcs.set_use_tls(tls);
    // Log in.
    CustomXmppPump pump;
    pump.client()->SignalLogInput.connect(&debug_log_, &DebugLog::Input);
    pump.client()->SignalLogOutput.connect(&debug_log_, &DebugLog::Output);
    pump.DoLogin(xcs, new XmppSocket(tls), 0);
    // Wait until login succeeds.
    std::vector<uint32> ids;
    ids.push_back(MSG_LOGIN_COMPLETE);
    ids.push_back(MSG_LOGIN_FAILED);
    if (MSG_LOGIN_FAILED == Loop(ids))
        throw "Failed to connect";
    ...
    // Runs the current thread until a message with the given ID is seen.
    uint32 Loop(const std::vector<uint32>& ids) {
      talk_base::Message msg;
      while (talk_base::Thread::Current()->Get(&msg)) {
        cout << "received message: " << msg.message_id << endl;
        if (msg.phandler == NULL) {
          if (std::find(ids.begin(), ids.end(), msg.message_id) != ids.end())
            return msg.message_id;
          std::cout << "orphaned message: " << msg.message_id << endl;
          continue;
        }
        cout << "1: " << msg.message_id <<  " : " << msg.ts_sensitive << endl;
        talk_base::Thread::Current()->Dispatch(&msg);
        cout << "2: " << msg.message_id << endl;
      }
      return 0;
    }
実行すると、次のように出力されます。
接続中... 受信メッセージ: 0 1:0:0 [004:722] PhysicalSocket::Connect で addr を解決しています 2:0 受信メッセージ: 0 1:0:0 2:0
ハングアップするだけなので、Get(&msg) 呼び出しでスタックしていることは明らかです。
私のサーバーは DNS SRV レコードを使用しており、他のクライアントと正常に動作することに注意してください。SRV を自分で解決する必要があるだけでしょうか?
助けてくれてありがとう!