Skip to content

Commit 44f5a4d

Browse files
committed
Fix Client returning disconnected because of VFS errors
1 parent e63aa40 commit 44f5a4d

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

Diff for: libraries/WiFi/src/WiFiClient.cpp

+17-3
Original file line numberDiff line numberDiff line change
@@ -438,9 +438,23 @@ uint8_t WiFiClient::connected()
438438
if (_connected) {
439439
uint8_t dummy;
440440
int res = recv(fd(), &dummy, 0, MSG_DONTWAIT);
441-
if (res <= 0 && errno != EWOULDBLOCK) {
442-
_connected = false;
443-
log_i("Disconnected: RES: %d, ERR: %d", res, errno);
441+
switch (errno) {
442+
case EWOULDBLOCK:
443+
case ENOENT: //caused by vfs
444+
_connected = true;
445+
break;
446+
case ENOTCONN:
447+
case EPIPE:
448+
case ECONNRESET:
449+
case ECONNREFUSED:
450+
case ECONNABORTED:
451+
_connected = false;
452+
log_d("Disconnected: RES: %d, ERR: %d", res, errno);
453+
break;
454+
default:
455+
log_i("Unexpected: RES: %d, ERR: %d", res, errno);
456+
_connected = true;
457+
break;
444458
}
445459
}
446460
return _connected;

0 commit comments

Comments
 (0)