- bool old_notify_state = m_notify_state;
- int state = -1;
- _wxSocketInternalTimer timer;
-
- if ((!m_connected && !m_establishing) || !m_socket)
- return FALSE;
-
- // Set the variable to change
- timer.m_state = &state;
- timer.m_new_val = GSOCK_MAX_EVENT;
-
- // Disable the previous handler
- Notify(FALSE);
-
- // Set the timeout
- timer.Start(seconds * 1000 + milliseconds, TRUE);
- GSocket_SetCallback(m_socket, type, wx_socket_wait, (char *)&state);
-
- while (state == -1)
- wxYield();
-
- GSocket_UnsetCallback(m_socket, type);
- timer.Stop();
-
- // Notify will restore automatically the old GSocket flags
- Notify(old_notify_state);
-
- // GRG: If a LOST event occured, we set m_establishing to
- // FALSE here (this is a quick hack to make WaitOnConnect
- // work; it will be removed when this function is modified
- // so that it tells the caller which event occured).
- //
- if (state == GSOCK_LOST)
- m_establishing = FALSE;