diff --git a/psk/server-psk-nonblocking.c b/psk/server-psk-nonblocking.c index cfbdabca1..6b4ed2cc2 100644 --- a/psk/server-psk-nonblocking.c +++ b/psk/server-psk-nonblocking.c @@ -146,6 +146,12 @@ int main() return 1; } + /* listen to the socket */ + if (listen(listenfd, LISTENQ) < 0) { + printf("Fatal error : listen error\n"); + return 1; + } + wolfSSL_Init(); if ((ctx = wolfSSL_CTX_new(wolfSSLv23_server_method())) == NULL) { @@ -180,12 +186,6 @@ int main() for ( ; ; ) { WOLFSSL* ssl; - /* listen to the socket */ - if (listen(listenfd, LISTENQ) < 0) { - printf("Fatal error : listen error\n"); - return 1; - } - cliLen = sizeof(cliAddr); connfd = accept(listenfd, (struct sockaddr *) &cliAddr, &cliLen); if (connfd < 0) { diff --git a/psk/server-psk-threaded.c b/psk/server-psk-threaded.c index c2682e056..444bbf4f3 100644 --- a/psk/server-psk-threaded.c +++ b/psk/server-psk-threaded.c @@ -188,6 +188,12 @@ int main() return 1; } + /* listen to the socket */ + if (listen(listenfd, LISTENQ) < 0) { + printf("Fatal error : listen error"); + return 1; + } + wolfSSL_Init(); if ((ctx = wolfSSL_CTX_new(wolfSSLv23_server_method())) == NULL) { @@ -221,12 +227,6 @@ int main() /* main loop for accepting and responding to clients */ for ( ; ; ) { - /* listen to the socket */ - if (listen(listenfd, LISTENQ) < 0) { - printf("Fatal error : listen error"); - return 1; - } - cliLen = sizeof(cliAddr); connfd = accept(listenfd, (struct sockaddr *) &cliAddr, &cliLen); if (connfd < 0) {