- // WaitOnConnect() itself never blocks the GUI (this might change
- // in the future to honour the wxSOCKET_BLOCK flag). This call will
- // return false on timeout, or true if the connection request
- // completes, which in turn might mean:
- //
- // a) That the connection was successfully established
- // b) That the connection request failed (for example, because
- // it was refused by the peer.
- //
- // Use IsConnected() to distinguish between these two.
- //
- // So, in a brief, you should do one of the following things:
- //
- // For blocking Connect:
- //
- // bool success = client->Connect(addr, true);
- //
- // For nonblocking Connect:
- //
- // client->Connect(addr, false);
- //
- // bool waitmore = true;
- // while (! client->WaitOnConnect(seconds, millis) && waitmore )
- // {
- // // possibly give some feedback to the user,
- // // update waitmore if needed.
- // }
- // bool success = client->IsConnected();
- //
- // And that's all :-)
-
- m_text->AppendText(_("\nTrying to connect (timeout = 10 sec) ...\n"));
- m_sock->Connect(addr, false);
- m_sock->WaitOnConnect(10);
-
- if (m_sock->IsConnected())
- m_text->AppendText(_("Succeeded ! Connection established\n"));
- else
- {
- m_sock->Close();
- m_text->AppendText(_("Failed ! Unable to connect\n"));
- wxMessageBox(_("Can't connect to the specified host"), _("Alert !"));
- }
-
- UpdateStatusBar();
+ // if you want to make sure that connection is established right here you
+ // could call WaitOnConnect(timeout) instead
+ wxLogMessage("Trying to connect to %s:%d", hostname, addr->Service());
+
+ m_sock->Connect(*addr, false);