From 4e9d1ee23798a127b6754d199194adcbee21f058 Mon Sep 17 00:00:00 2001 From: me-no-dev Date: Tue, 10 Jul 2018 21:05:44 +0200 Subject: [PATCH] Fix connected to be wrongly reported in WiFiClient --- libraries/WiFi/src/WiFiClient.cpp | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/libraries/WiFi/src/WiFiClient.cpp b/libraries/WiFi/src/WiFiClient.cpp index be8c41c9..ddd9fd7c 100644 --- a/libraries/WiFi/src/WiFiClient.cpp +++ b/libraries/WiFi/src/WiFiClient.cpp @@ -438,23 +438,9 @@ uint8_t WiFiClient::connected() if (_connected) { uint8_t dummy; int res = recv(fd(), &dummy, 0, MSG_DONTWAIT); - if (res < 0) { - switch (errno) { - case ENOTCONN: - case EPIPE: - case ECONNRESET: - case ECONNREFUSED: - case ECONNABORTED: - _connected = false; - break; - default: - _connected = true; - break; - } - } else if(res == 0){ + if (res <= 0 && errno != EWOULDBLOCK) { _connected = false; - } else { - _connected = true; + log_i("Disconnected: RES: %d, ERR: %d", res, errno); } } return _connected;