Fix connected to be wrongly reported in WiFiClient

This commit is contained in:
me-no-dev 2018-07-10 21:05:44 +02:00
parent c1a94b5326
commit 4e9d1ee237

View File

@ -438,23 +438,9 @@ uint8_t WiFiClient::connected()
if (_connected) { if (_connected) {
uint8_t dummy; uint8_t dummy;
int res = recv(fd(), &dummy, 0, MSG_DONTWAIT); int res = recv(fd(), &dummy, 0, MSG_DONTWAIT);
if (res < 0) { if (res <= 0 && errno != EWOULDBLOCK) {
switch (errno) {
case ENOTCONN:
case EPIPE:
case ECONNRESET:
case ECONNREFUSED:
case ECONNABORTED:
_connected = false; _connected = false;
break; log_i("Disconnected: RES: %d, ERR: %d", res, errno);
default:
_connected = true;
break;
}
} else if(res == 0){
_connected = false;
} else {
_connected = true;
} }
} }
return _connected; return _connected;