diff --git a/libraries/WiFi/src/WiFiClient.cpp b/libraries/WiFi/src/WiFiClient.cpp index e422b636..52df2731 100644 --- a/libraries/WiFi/src/WiFiClient.cpp +++ b/libraries/WiFi/src/WiFiClient.cpp @@ -105,7 +105,7 @@ public: int read(uint8_t * dst, size_t len){ if(!dst || !len || (_pos == _fill && !fillBuffer())){ - return -1; + return _failed ? -1 : 0; } size_t a = _fill - _pos; if(len <= a || ((len - a) <= (_size - _fill) && fillBuffer() >= (len - a))){ @@ -346,6 +346,9 @@ int WiFiClient::read() if(res < 0) { return res; } + if (res == 0) { // No data available. + return -1; + } return data; }