From ec1ed04edf352ea44481ddcd81b89efd3b47d684 Mon Sep 17 00:00:00 2001 From: George Tong Date: Mon, 7 Nov 2022 16:37:48 -0800 Subject: [PATCH] Set socket to invalid socket if connection fails --- src/EthernetClient.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EthernetClient.cpp b/src/EthernetClient.cpp index 5a20c748..8f9ab081 100644 --- a/src/EthernetClient.cpp +++ b/src/EthernetClient.cpp @@ -60,7 +60,7 @@ int EthernetClient::connect(IPAddress ip, uint16_t port) uint8_t stat = Ethernet.socketStatus(_sockindex); if (stat == SnSR::ESTABLISHED) return 1; if (stat == SnSR::CLOSE_WAIT) return 1; - if (stat == SnSR::CLOSED) return 0; + if (stat == SnSR::CLOSED) break; if (millis() - start > _timeout) break; delay(1); }