#include <stdlib.h>
#endif
+#include <time.h> // for timeval
+
enum GAddressType
{
GSOCK_NOFAMILY = 0,
bool m_broadcast;
bool m_dobind;
-#ifdef __WINDOWS__
struct timeval m_timeout;
-#else
- unsigned long m_timeout;
-#endif
GSocketEventFlags m_detected;
*/
void GSocketBase::SetTimeout(unsigned long millis)
{
-#ifdef __WXMSW__
m_timeout.tv_sec = (millis / 1000);
m_timeout.tv_usec = (millis % 1000) * 1000;
-#else
- m_timeout = millis;
-#endif
}
void GSocketBase::NotifyOnStateChange(GSocketEvent event)
*/
GSocketError GSocket::Input_Timeout()
{
- struct timeval tv;
fd_set readfds;
int ret;
- /* Linux select() will overwrite the struct on return */
- tv.tv_sec = (m_timeout / 1000);
- tv.tv_usec = (m_timeout % 1000) * 1000;
+ // Linux select() will overwrite the struct on return so make a copy
+ struct timeval tv = m_timeout;
if (!m_non_blocking)
{
*/
GSocketError GSocket::Output_Timeout()
{
- struct timeval tv;
fd_set writefds;
int ret;
- /* Linux select() will overwrite the struct on return */
- tv.tv_sec = (m_timeout / 1000);
- tv.tv_usec = (m_timeout % 1000) * 1000;
+ // Linux select() will overwrite the struct on return so make a copy
+ struct timeval tv = m_timeout;
GSocket_Debug( ("m_non_blocking has: %d\n", (int)m_non_blocking) );