- // 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 = Connect(addr, TRUE);
- //
- // For nonblocking Connect:
- //
- // Connect(addr, FALSE);
- //
- // bool waitmore;
- // while (!WaitOnConnect(seconds, millis) && waitmore)
- // {
- // // possibly give some feedback to the user,
- // // update waitmore if needed.
- // }
- // bool success = 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);