Skip to content

Commit b645b4a

Browse files
committed
Return sensible values from Client::connected() and Client::status() if we know it's not connected.
1 parent d5dc704 commit b645b4a

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Client.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,15 @@ void Client::stop() {
109109
}
110110

111111
uint8_t Client::connected() {
112+
if (!_connected) return 0;
113+
112114
uint8_t s = status();
113115
return !(s == SnSR::LISTEN || s == SnSR::CLOSED || s == SnSR::FIN_WAIT ||
114116
(s == SnSR::CLOSE_WAIT && !available()));
115117
}
116118

117119
uint8_t Client::status() {
120+
if (!_connected) return SnSR::CLOSED;
118121
return W5100.readSnSR(_sock);
119122
}
120123

0 commit comments

Comments
 (0)