- unsigned long timeout)
-{
- wxSocketEventFlags result = 0;
-
- if (m_fd == INVALID_SOCKET)
- return (wxSOCKET_LOST_FLAG & flags);
-
- struct timeval tv;
- SetTimeValFromMS(tv, timeout);
-
- fd_set readfds;
- fd_set writefds;
- fd_set exceptfds;
- wxFD_ZERO(&readfds);
- wxFD_ZERO(&writefds);
- wxFD_ZERO(&exceptfds);
- wxFD_SET(m_fd, &readfds);
- if (flags & wxSOCKET_OUTPUT_FLAG || flags & wxSOCKET_CONNECTION_FLAG)
- wxFD_SET(m_fd, &writefds);
- wxFD_SET(m_fd, &exceptfds);
-
- /* Check 'sticky' CONNECTION flag first */
- result |= wxSOCKET_CONNECTION_FLAG & m_detected;
-
- /* If we have already detected a LOST event, then don't try
- * to do any further processing.
- */
- if ((m_detected & wxSOCKET_LOST_FLAG) != 0)
- {
- m_establishing = false;
- return (wxSOCKET_LOST_FLAG & flags);
- }
-
- /* Try select now */
- if (select(m_fd + 1, &readfds, &writefds, &exceptfds, &tv) < 0)
- {
- /* What to do here? */
- return (result & flags);
- }
-
- /* Check for exceptions and errors */
- if (wxFD_ISSET(m_fd, &exceptfds))
- {
- m_establishing = false;
- m_detected = wxSOCKET_LOST_FLAG;