Skip to content

Commit

Permalink
Fix ezsockets timeout on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
nico-abram authored Jun 23, 2018
1 parent 75067d5 commit ed6ff64
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/ezsockets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,14 @@ bool EzSockets::create(int Protocol, int Type)
state = skDISCONNECTED;
sock = socket(AF_INET, Type, Protocol);
if (sock > SOCKET_NONE) {
#if defined(WIN32)
int tv = timeoutSeconds*1000;
#else
struct timeval tv;
tv.tv_sec = timeoutSeconds;
tv.tv_usec = 0;
setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (const char *)&tv, sizeof(struct timeval));
#endif
setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (const char *)&tv, sizeof(tv));
}
lastCode = sock;
return sock > SOCKET_NONE; // Socket must be Greater than 0
Expand Down

0 comments on commit ed6ff64

Please sign in to comment.