Skip to content

Commit 6338d67

Browse files
committed
Re-arm the select timeout each pass in the nonblocking dtls server
1 parent 6eb6a90 commit 6338d67

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

dtls/server-dtls-nonblocking.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ int main(int argc, char** argv)
142142

143143
clilen = sizeof(cliAddr);
144144
timeout.tv_sec = (currTimeout > 0) ? currTimeout : 0;
145+
timeout.tv_usec = 0;
145146

146147
/* Create a UDP/IP socket */
147148
if ((listenfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0 ) {
@@ -266,6 +267,9 @@ int main(int argc, char** argv)
266267
printf("... server would write block\n");
267268

268269
currTimeout = wolfSSL_dtls_get_current_timeout(ssl);
270+
/* select() consumes the timeout, so re-arm it every pass */
271+
timeout.tv_sec = (currTimeout > 0) ? currTimeout : 0;
272+
timeout.tv_usec = 0;
269273

270274
FD_ZERO(&recvfds);
271275
FD_SET(listenfd, &recvfds);

0 commit comments

Comments
 (0)