From a2ab207446d591778a35b71bb9e5df5e160bfdcd Mon Sep 17 00:00:00 2001 From: pablo2048 Date: Sat, 4 Feb 2023 18:38:43 +0100 Subject: [PATCH] Fix https://github.com/me-no-dev/ESPAsyncTCP/pull/138 --- src/ESPAsyncTCP.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ESPAsyncTCP.cpp b/src/ESPAsyncTCP.cpp index 39b34cc..ce24d50 100644 --- a/src/ESPAsyncTCP.cpp +++ b/src/ESPAsyncTCP.cpp @@ -265,6 +265,9 @@ bool AsyncClient::connect(IPAddress ip, uint16_t port){ tcp_arg(pcb, this); tcp_err(pcb, &_s_error); size_t err = tcp_connect(pcb, &addr, port,(tcp_connected_fn)&_s_connected); + if (err != ERR_OK) { + tcp_close(pcb); + } return (ERR_OK == err); }