win32 SO_RCVTIMEO

This commit is contained in:
Matej Sekoranja
2014-11-20 23:06:32 +01:00
parent 976fe49d60
commit d654738dc5

View File

@ -275,11 +275,15 @@ bool discoverServers(double timeOut)
} }
// set timeout // set timeout
#ifdef _WIN32
// ms
DWORD timeout = 250;
#else
struct timeval timeout; struct timeval timeout;
memset(&timeout, 0, sizeof(struct timeval)); memset(&timeout, 0, sizeof(struct timeval));
timeout.tv_sec = 0; timeout.tv_sec = 0;
timeout.tv_usec = 250000; timeout.tv_usec = 250000;
#endif
status = ::setsockopt (socket, SOL_SOCKET, SO_RCVTIMEO, status = ::setsockopt (socket, SOL_SOCKET, SO_RCVTIMEO,
(char*)&timeout, sizeof(timeout)); (char*)&timeout, sizeof(timeout));
if (status) if (status)
@ -377,7 +381,7 @@ bool discoverServers(double timeOut)
if (socketError == SOCK_EINTR || if (socketError == SOCK_EINTR ||
socketError == EAGAIN || // no alias in libCom socketError == EAGAIN || // no alias in libCom
// windows times out with this // windows times out with this
//socketError == SOCK_ETIMEDOUT || socketError == SOCK_ETIMEDOUT ||
socketError == SOCK_EWOULDBLOCK) socketError == SOCK_EWOULDBLOCK)
{ {
// OK // OK