Fix Client returning disconnected because of VFS errors

This commit is contained in:
me-no-dev 2018-07-16 20:08:27 +02:00
parent e63aa40650
commit 44f5a4dbc8

View File

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