From 97b6f592c3969a54d754b5e7fe69544fdfc1665e Mon Sep 17 00:00:00 2001 From: Andrea Gilardoni Date: Wed, 28 Aug 2024 11:37:25 +0200 Subject: [PATCH] enforcing stop() when calling connect a second time --- libraries/SocketWrapper/src/MbedClient.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/libraries/SocketWrapper/src/MbedClient.cpp b/libraries/SocketWrapper/src/MbedClient.cpp index ad74db1ca..f50ff18b7 100644 --- a/libraries/SocketWrapper/src/MbedClient.cpp +++ b/libraries/SocketWrapper/src/MbedClient.cpp @@ -80,14 +80,8 @@ void arduino::MbedClient::configureSocket(Socket *_s) { } int arduino::MbedClient::connect(SocketAddress socketAddress) { - - if (sock && reader_th) { - // trying to reuse a connection, let's call stop() to cleanup the state - char c; - if (sock->recv(&c, 1) < 0) { - stop(); - } - } + // if a connection is aready ongoing, a disconnection must be enforced before starting another one + stop(); if (sock == nullptr) { sock = new TCPSocket(); @@ -135,6 +129,9 @@ int arduino::MbedClient::connect(const char *host, uint16_t port) { } int arduino::MbedClient::connectSSL(SocketAddress socketAddress) { + // if a connection is aready ongoing, a disconnection must be enforced before starting another one + stop(); + if (sock == nullptr) { sock = new TLSSocket(); _own_socket = true; pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy