-wxSocketEventFlags wxSocketImpl::Select(wxSocketEventFlags flags)
-{
- assert(this);
-
- wxSocketEventFlags result = 0;
- fd_set readfds;
- fd_set writefds;
- fd_set exceptfds;
- struct timeval tv;
-
- if (m_fd == -1)
- return (wxSOCKET_LOST_FLAG & flags);
-
- /* Do not use a static struct, Linux can garble it */
- tv.tv_sec = 0;
- tv.tv_usec = 0;
-
- 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;
+wxSocketEventFlags wxSocketImpl::Select(wxSocketEventFlags flags,
+ const timeval *timeout)
+{
+ if ( m_fd == INVALID_SOCKET )
+ return (wxSOCKET_LOST_FLAG & flags);