else
timeout = m_timeout * 1000;
+#if !defined(wxUSE_GUI) || !wxUSE_GUI
+ GSocket_SetTimeout(m_socket, timeout);
+#endif
+
// Wait in an active polling loop.
//
// NOTE: We duplicate some of the code in OnRequest, but this doesn't
fd_set readfds;
fd_set writefds;
fd_set exceptfds;
- static const struct timeval tv = { 0, 0 };
-
+
assert(socket != NULL);
FD_ZERO(&readfds);
FD_ZERO(&writefds);
FD_ZERO(&exceptfds);
FD_SET(socket->m_fd, &readfds);
- FD_SET(socket->m_fd, &writefds);
+ if (flags & GSOCK_OUTPUT_FLAG)
+ FD_SET(socket->m_fd, &writefds);
FD_SET(socket->m_fd, &exceptfds);
/* Check 'sticky' CONNECTION flag first */
}
/* Try select now */
- if (select(socket->m_fd + 1, &readfds, &writefds, &exceptfds, &tv) <= 0)
+ if (select(socket->m_fd + 1, &readfds, &writefds, &exceptfds,
+ &socket->m_timeout) <= 0)
{
/* What to do here? */
return (result & flags);
{
char c;
- if (recv(socket->m_fd, &c, 1, MSG_PEEK) > 0)
+ if (!socket->m_stream || recv(socket->m_fd, &c, 1, MSG_PEEK) > 0)
{
result |= GSOCK_INPUT_FLAG;
}
struct timeval tv;
/* Do not use a static struct, Linux can garble it */
- tv.tv_sec = 0;
- tv.tv_usec = 0;
+ tv.tv_sec = socket->m_timeout / 1000;
+ tv.tv_usec = (socket->m_timeout % 1000) / 1000;
assert(socket != NULL);
FD_ZERO(&writefds);
FD_ZERO(&exceptfds);
FD_SET(socket->m_fd, &readfds);
- FD_SET(socket->m_fd, &writefds);
+ if (flags & GSOCK_OUTPUT_FLAG)
+ FD_SET(socket->m_fd, &writefds);
FD_SET(socket->m_fd, &exceptfds);
/* Check 'sticky' CONNECTION flag first */