-wxUint32 wxSocketBase::DeferRead(char *buffer, wxUint32 nbytes)
-{
- // Timer for timeout
- _wxSocketInternalTimer timer;
-
- //wxLogMessage("Entrando a DeferRead, nbytes = %d", nbytes);
- wxASSERT(m_defering == NO_DEFER);
-
- // Set the defering mode to READ.
- m_defering = DEFER_READ;
-
- // Set the current buffer.
- m_defer_buffer = buffer;
- m_defer_nbytes = nbytes;
- m_defer_timer = &timer;
-
- timer.m_state = (int *)&m_defer_buffer;
- timer.m_new_val = 0;
-
- timer.Start(m_timeout * 1000, FALSE);
-
- // If the socket is readable, call DoDefer for the first time
- if (GSocket_Select(m_socket, GSOCK_INPUT_FLAG))
- {
- //wxLogMessage("Llamando al primer DoDefer");
- DoDefer();
- }
-
- // Wait for buffer completion.
- while (m_defer_buffer != NULL)
- wxYield();
-
- timer.Stop();
-
- // Disable defering mode.
- m_defering = NO_DEFER;
- m_defer_timer = NULL;
-
- // Return the number of bytes read from the socket.
- //wxLogMessage("Saliendo de DeferRead: total: %d bytes", nbytes - m_defer_nbytes);
- return nbytes-m_defer_nbytes;
-}
-