Address other examples also based on peer feedback
parent
f45184fc4a
commit
5195bdbd31
|
@ -159,7 +159,6 @@ WOLFSSL* Client(WOLFSSL_CTX* ctx, char* suite, int setSuite, int doVerify)
|
|||
}
|
||||
|
||||
wolfSSL_set_fd(ssl, fpRecv);
|
||||
wolfSSL_set_using_nonblock(ssl, fpRecv);
|
||||
|
||||
return ssl;
|
||||
}
|
||||
|
|
|
@ -150,7 +150,6 @@ WOLFSSL* Server(WOLFSSL_CTX* ctx, char* suite, int setSuite)
|
|||
}
|
||||
|
||||
wolfSSL_set_fd(ssl, fpRecv);
|
||||
wolfSSL_set_using_nonblock(ssl, fpRecv);
|
||||
return ssl;
|
||||
}
|
||||
|
||||
|
|
|
@ -1198,7 +1198,7 @@ The only part of the functionality that is truly nonblocking is the selection of
|
|||
|
||||
Before adding anything else, there are 2 method calls to be added. In the `main()` method, add the following chunk **immediately** after the call to `wolfSSL_set_fd(ssl, sockfd)`:
|
||||
```c
|
||||
wolfSSL_set_using_nonblock(ssl, 1);
|
||||
wolfSSL_dtls_set_using_nonblock(ssl, 1);
|
||||
fcntl(sockfd, F_SETFL, O_NONBLOCK);
|
||||
```
|
||||
##### 5.1.4.1 - Variables
|
||||
|
@ -1400,9 +1400,9 @@ To make our server a nonblocking server, we need to add 2 things. They are the s
|
|||
|
||||
**2. A while loop that loops while cleanup is not 1 and the original conditions are true**
|
||||
|
||||
Don't forget that immediately after the call to `wolfSSL_set_fd()`, we need to make a call `wolfSSL_set_using_nonblock()`. The call to this method is shown below.
|
||||
Don't forget that immediately after the call to `wolfSSL_set_fd()`, we need to make a call `wolfSSL_dtls_set_using_nonblock()`. The call to this method is shown below.
|
||||
```c
|
||||
wolfSSL_set_using_nonblock(ssl, 1);
|
||||
wolfSSL_dtls_set_using_nonblock(ssl, 1);
|
||||
```
|
||||
##### 5.2.4.1 Variables
|
||||
As with our client, there are several variables needed for our nonblocking DTLS server. **Figure 5.7** lists them.
|
||||
|
@ -1525,7 +1525,7 @@ while (cleanup != 1) {
|
|||
/* set the/ session ssl to client connection port */
|
||||
wolfSSL_set_fd(ssl, clientfd);
|
||||
|
||||
wolfSSL_set_using_nonblock(ssl, 1);
|
||||
wolfSSL_dtls_set_using_nonblock(ssl, 1);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* NonBlockingDTLS_Connect code */
|
||||
|
|
|
@ -187,11 +187,6 @@ static int wolfssl_client_new(WOLFSSL_CTX** ctx, WOLFSSL** ssl)
|
|||
}
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
/* make wolfSSL object nonblocking */
|
||||
wolfSSL_set_using_nonblock(client_ssl, 1);
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
*ctx = client_ctx;
|
||||
*ssl = client_ssl;
|
||||
|
@ -273,11 +268,6 @@ static int wolfssl_server_new(WOLFSSL_CTX** ctx, WOLFSSL** ssl)
|
|||
}
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
/* make wolfSSL object nonblocking */
|
||||
wolfSSL_set_using_nonblock(server_ssl, 1);
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
*ctx = server_ctx;
|
||||
*ssl = server_ssl;
|
||||
|
|
|
@ -160,11 +160,6 @@ static int wolfssl_server_new(WOLFSSL_CTX** ctx, WOLFSSL** ssl)
|
|||
}
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
/* make wolfSSL object nonblocking */
|
||||
wolfSSL_set_using_nonblock(server_ssl, 1);
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
*ctx = server_ctx;
|
||||
*ssl = server_ssl;
|
||||
|
|
|
@ -100,11 +100,6 @@ static int wolfssl_client_ssl_new(WOLFSSL_CTX* ctx, WOLFSSL** ssl)
|
|||
ret = -1;
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
/* make wolfSSL object nonblocking */
|
||||
wolfSSL_set_using_nonblock(client_ssl, 1);
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
/* Return newly created wolfSSL object */
|
||||
*ssl = client_ssl;
|
||||
|
|
|
@ -80,11 +80,6 @@ static int wolfssl_client_ssl_new(WOLFSSL_CTX* ctx, WOLFSSL** ssl)
|
|||
ret = -1;
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
/* make wolfSSL object nonblocking */
|
||||
wolfSSL_set_using_nonblock(client_ssl, 1);
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
/* Return newly created wolfSSL object */
|
||||
*ssl = client_ssl;
|
||||
|
|
|
@ -116,11 +116,6 @@ static int wolfssl_server_ssl_new(WOLFSSL_CTX* ctx, WOLFSSL** ssl)
|
|||
}
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
/* make wolfSSL object nonblocking */
|
||||
wolfSSL_set_using_nonblock(server_ssl, 1);
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
/* Return newly created wolfSSL context and object */
|
||||
*ssl = server_ssl;
|
||||
|
|
|
@ -102,11 +102,6 @@ static int wolfssl_server_ssl_new(WOLFSSL_CTX* ctx, WOLFSSL** ssl)
|
|||
}
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
/* make wolfSSL object nonblocking */
|
||||
wolfSSL_set_using_nonblock(server_ssl, 1);
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
/* Return newly created wolfSSL context and object */
|
||||
*ssl = server_ssl;
|
||||
|
|
|
@ -82,11 +82,6 @@ static int wolfssl_client_new(WOLFSSL_CTX** ctx, WOLFSSL** ssl)
|
|||
}
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
/* make wolfSSL object nonblocking */
|
||||
wolfSSL_set_using_nonblock(client_ssl, 1);
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
/* Return newly created wolfSSL context and object */
|
||||
*ctx = client_ctx;
|
||||
|
@ -159,11 +154,6 @@ static int wolfssl_server_new(WOLFSSL_CTX** ctx, WOLFSSL** ssl)
|
|||
}
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
/* make wolfSSL object nonblocking */
|
||||
wolfSSL_set_using_nonblock(server_ssl, 1);
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
/* Return newly created wolfSSL context and object */
|
||||
*ctx = server_ctx;
|
||||
|
|
|
@ -181,11 +181,6 @@ static int wolfssl_client_new(WOLFSSL_CTX** ctx, WOLFSSL** ssl)
|
|||
}
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
/* make wolfSSL object nonblocking */
|
||||
wolfSSL_set_using_nonblock(client_ssl, 1);
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
/* Return newly created wolfSSL context and object */
|
||||
*ctx = client_ctx;
|
||||
|
@ -261,11 +256,6 @@ static int wolfssl_server_new(WOLFSSL_CTX** ctx, WOLFSSL** ssl)
|
|||
}
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
/* make wolfSSL object nonblocking */
|
||||
wolfSSL_set_using_nonblock(server_ssl, 1);
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
/* Return newly created wolfSSL context and object */
|
||||
*ctx = server_ctx;
|
||||
|
|
|
@ -82,7 +82,7 @@ TCP/PSK Tutorial
|
|||
|
||||
1. Include the fcntl.h header file. This is needed for some of the constants that will be used when dealing with non-blocking on the socket. `` #include <fcntl.h>``
|
||||
|
||||
2. After the function ``wolfSSL_set_fd(ssl,sockfd)``, tell wolfSSL that you want non-blocking to be used. This is done by adding : `` wolfSSL_set_using_nonblock(ssl,1);``
|
||||
2. NOTE: TLS is nonblocking by default, just make sure the sockets are configured to be non-blocking sockets
|
||||
|
||||
3. Now we must invoke the fcntl callable serve to use non-blocking.
|
||||
|
||||
|
@ -375,9 +375,7 @@ When a socket is setup as non-blocking, reads and writes to the socket do not ca
|
|||
|
||||
``#include <fcntl.h>``
|
||||
|
||||
2. After the function wolfSSL_set_fd(ssl, sockfd), tell wolfssl that you want nonblocking to be used. This is done by adding:
|
||||
|
||||
``wolfSSL_set_using_nonblock(ssl,1);``
|
||||
2. NOTE: TLS is nonblocking by default, just make sure the sockets are configured to be non-blocking sockets
|
||||
|
||||
3. Now we much invoke the fcntl callable serve to use nonblocking. This is done by adding:
|
||||
|
||||
|
@ -502,8 +500,7 @@ Nonblocking on the server side allows for switching between multiple client conn
|
|||
1. Include the fcntl.h header file. This is needed for some of the constants that will be used when dealing with non blocking on the socket.
|
||||
``#include <fcntl.h>``
|
||||
|
||||
2. After accept has found a client and an ssl object has been made and associated with the clients socket then call the wolfSSL function to set wolfSSL in non blocking mode. This is done using the following function call.
|
||||
``wolfSSL_set_using_nonblock(ssl, 1);``
|
||||
2. NOTE: TLS is nonblocking by default, just make sure the sockets are configured to be non-blocking sockets
|
||||
|
||||
3. Immediately after setting wolfSSL to use non blocking, the socket that the client is connected on needs to also be set up to be non blocking. This is done using the included fcntl.h and making the following function call.
|
||||
|
||||
|
|
|
@ -492,7 +492,6 @@ static int SSLConn_Connect(SSLConn_CTX* ctx, WOLFSSL_CTX* sslCtx, int sockfd,
|
|||
sslConn->state = CONNECT;
|
||||
/* Set the socket to communicate over. */
|
||||
wolfSSL_set_fd(sslConn->ssl, sslConn->sockfd);
|
||||
wolfSSL_set_using_nonblock(sslConn->ssl, 1);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -481,7 +481,6 @@ static int SSLConn_Accept(SSLConn_CTX* ctx, WOLFSSL_CTX* sslCtx,
|
|||
}
|
||||
/* Set the socket to communicate over into the wolfSSL object. */
|
||||
wolfSSL_set_fd(conn->ssl, conn->sockfd);
|
||||
wolfSSL_set_using_nonblock(conn->ssl, 1);
|
||||
|
||||
conn->state = ACCEPT;
|
||||
conn->next = ctx->sslConn;
|
||||
|
|
|
@ -589,7 +589,6 @@ static int SSLConn_Accept(ThreadData* threadData, WOLFSSL_CTX* sslCtx,
|
|||
}
|
||||
/* Set the socket to communicate over into the wolfSSL object. */
|
||||
wolfSSL_set_fd(conn->ssl, conn->sockfd);
|
||||
wolfSSL_set_using_nonblock(conn->ssl, 1);
|
||||
|
||||
conn->state = ACCEPT;
|
||||
conn->next = threadData->sslConn;
|
||||
|
|
Loading…
Reference in New Issue