-// --------------------------------------------------------------
-// --------- wxSocketBase callback functions --------------------
-// --------------------------------------------------------------
-
-wxSocketBase::wxSockCbk wxSocketBase::Callback(wxSockCbk cbk_)
-{
- wxSockCbk old_cbk = cbk_;
-
- m_cbk = cbk_;
- return old_cbk;
-}
-
-char *wxSocketBase::CallbackData(char *data)
-{
- char *old_data = m_cdata;
-
- m_cdata = data;
- return old_data;
-}
-
-// --------------------------------------------------------------
-// --------- wxSocketBase wait functions ------------------------
-// --------------------------------------------------------------
-
-static void wx_socket_wait(GSocket *socket, GSocketEvent event, char *cdata)
-{
- int *state = (int *)cdata;
-
- *state = event;
-}
-
-bool wxSocketBase::_Wait(long seconds, long milliseconds, int type)
-{
- 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;
-
- return (state != GSOCK_MAX_EVENT);
-}
-
-bool wxSocketBase::Wait(long seconds, long milliseconds)
-{
- return _Wait(seconds, milliseconds, GSOCK_INPUT_FLAG |
- GSOCK_OUTPUT_FLAG |
- GSOCK_CONNECTION_FLAG |
- GSOCK_LOST_FLAG);
-}
-
-bool wxSocketBase::WaitForRead(long seconds, long milliseconds)
-{
- return _Wait(seconds, milliseconds, GSOCK_INPUT_FLAG | GSOCK_LOST_FLAG);
-}
-
-bool wxSocketBase::WaitForWrite(long seconds, long milliseconds)
-{
- return _Wait(seconds, milliseconds, GSOCK_OUTPUT_FLAG | GSOCK_LOST_FLAG);
-}
-
-bool wxSocketBase::WaitForLost(long seconds, long milliseconds)
-{
- return _Wait(seconds, milliseconds, GSOCK_LOST_FLAG);
-}
-
-// --------------------------------------------------------------
-// --------- wxSocketBase callback management -------------------
-// --------------------------------------------------------------