-
-// --------------------------------------------------------------
-// wxSocketBase Wait functions
-// --------------------------------------------------------------
-
-// GRG: I have completely rewritten this family of functions
-// so that they don't depend on event notifications; instead,
-// they poll the socket, using GSocket_Select(), to check for
-// the specified combination of event flags, until an event
-// occurs or until the timeout ellapses. The polling loop
-// calls wxYield(), so this won't block the GUI.
-
-bool wxSocketBase::_Wait(long seconds, long milliseconds, wxSocketEventFlags flags)
-{
- GSocketEventFlags result;
- _wxSocketInternalTimer timer;
- long timeout;
- int state = -1;
-
- // Check for valid socket
- if ((!m_connected && !m_establishing) || !m_socket)
- return FALSE;
-
- // Check for valid timeout value
- if (seconds != -1)
- timeout = seconds * 1000 + milliseconds;
- else
- timeout = m_timeout * 1000;
-
- // Activate timer
- timer.m_state = &state;
- timer.m_new_val = 0;
- timer.Start(timeout, TRUE);
-
- // Active polling (without using events)
- result = GSocket_Select(m_socket, flags);
-
- while ((result == 0) && (state == -1))
- {
- wxYield();
- result = GSocket_Select(m_socket, flags);
- }
-
- timer.Stop();
-
- return (result != 0);
-}
-
-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);
-}