Skip to content

Commit ae0372d

Browse files
committed
dtls: client-threaded: remove 1 sec sleep between wolfSSL_Connect
1 parent dca8dab commit ae0372d

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

dtls/client-dtls-threaded.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ main(int argc,
116116
printf("error: pthread_create returned %d\n", ret);
117117
threads[i] = 0;
118118
}
119-
sleep(1);
120119
}
121120

122121
for (size_t i = 0; i < n_threads; ++i) {

dtls/server-dtls-threaded.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@
2121
*=============================================================================
2222
*
2323
* A simple dtls server example with configurable threadpool, for
24-
* instructional/learning purposes. Utilizes DTLS 1.2.
24+
* instructional/learning purposes. Utilizes DTLS 1.2. Please note that if
25+
* multiple client hellos arrive at the same time, the server might drop some of
26+
* them. A production-ready server needs a more sophisticated mechanism to
27+
* multiplex packets from different clients to the same port.
2528
*/
2629

2730
#include <wolfssl/options.h>
@@ -185,7 +188,11 @@ main(int argc,
185188
memset(&args[i], 0, sizeof(thread_args_t));
186189
args[i].activefd = listenfd;
187190
listenfd = new_udp_listen_socket();
188-
/* avoid messages from other peers */
191+
/* Avoid future packets from other peers to be received over
192+
* args[i].activefd. Please note that packets from other clients
193+
* already received might be returned from future invocations of
194+
* recvfrom()/read(). The args[i].ssl object will discard those packets
195+
* that don't match the set DTLS peer. */
189196
ret = connect(args[i].activefd, (const struct sockaddr *)&cliaddr, cliLen);
190197
if (ret != 0) {
191198
printf("error: connect returned: %d\n", ret);
@@ -200,7 +207,7 @@ main(int argc,
200207

201208
ret = wolfSSL_set_fd(args[i].ssl, args[i].activefd);
202209
if (ret != SSL_SUCCESS) {
203-
printf("error: wolfSSL_set_dtls_fd_connected: %d\n", ret);
210+
printf("error: wolfSSL_set_fd: %d\n", ret);
204211
break;
205212
}
206213

0 commit comments

Comments
 (0)