From 29d3878e148a1e084d1c9e7423fb8d1d46b74b42 Mon Sep 17 00:00:00 2001 From: abrahamsonn Date: Fri, 2 Jun 2017 13:43:54 -0600 Subject: [PATCH] Update client-dtls-nonblocking.c Moved variables to the top of the function --- dtls/client-dtls-nonblocking.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/dtls/client-dtls-nonblocking.c b/dtls/client-dtls-nonblocking.c index bd2ffc9f..ada26096 100644 --- a/dtls/client-dtls-nonblocking.c +++ b/dtls/client-dtls-nonblocking.c @@ -50,6 +50,7 @@ enum { int main (int argc, char** argv) { + /* standard variables used in a dtls client*/ int sockfd = 0; struct sockaddr_in servAddr; const char* host = argv[1]; @@ -60,6 +61,11 @@ int main (int argc, char** argv) char cert_array[] = "../certs/ca-cert.pem"; char* certs = cert_array; char* srTest = "testing session resume"; + /* variables used for non-blocking DTLS connect */ + int ret = wolfSSL_connect(ssl); + int error = wolfSSL_get_error(ssl, 0); + int nb_sockfd = (int) wolfSSL_get_fd(ssl); + int select_ret; if (argc != 2) { printf("usage: udpcli \n"); @@ -108,15 +114,10 @@ int main (int argc, char** argv) /*****************************************************************************/ /* Non-blocking code for DTLS connect */ - int ret = wolfSSL_connect(ssl); - int error = wolfSSL_get_error(ssl, 0); - int nb_sockfd = (int) wolfSSL_get_fd(ssl); - int select_ret; - while (ret != SSL_SUCCESS && (error == SSL_ERROR_WANT_READ || error == SSL_ERROR_WANT_WRITE)) { - /* Variables to reset each iteration */ + /* Variables that will reset upon every iteration */ int currTimeout = 1; int nfds = nb_sockfd +1; int result;