Skip to content

Commit

Permalink
tftpd.c: Fixed sread timeout on Windows by setting it manually
Browse files Browse the repository at this point in the history
  • Loading branch information
mback2k committed Apr 6, 2013
1 parent 34fa8d1 commit a181e7b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/server/tftpd.c
Expand Up @@ -1196,6 +1196,9 @@ static void sendtftp(struct testcase *test, struct formats *pf)
*/
static void recvtftp(struct testcase *test, struct formats *pf)
{
#if USE_WINSOCK
DWORD recvtimeout;
#endif
ssize_t n, size;
recvblock = 0;
#if defined(HAVE_ALARM) && defined(SIGALRM)
Expand Down Expand Up @@ -1265,7 +1268,17 @@ static void recvtftp(struct testcase *test, struct formats *pf)
alarm(rexmtval);
#endif
/* normally times out and quits */
#ifdef USE_WINSOCK
recvtimeout = 10;
setsockopt(peer, SOL_SOCKET, SO_RCVTIMEO,
(const char*)&recvtimeout, sizeof(recvtimeout));
#endif
n = sread(peer, &buf.storage[0], sizeof(buf.storage));
#ifdef USE_WINSOCK
recvtimeout = 0;
setsockopt(peer, SOL_SOCKET, SO_RCVTIMEO,
(const char*)&recvtimeout, sizeof(recvtimeout));
#endif
#ifdef HAVE_ALARM
alarm(0);
#endif
Expand Down

0 comments on commit a181e7b

Please sign in to comment.