mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-18 12:54:25 +01:00
Return sensible values from Client::connected() and Client::status() if we know it's not connected.
This commit is contained in:
parent
f6575c64df
commit
f5bb3ab541
@ -109,12 +109,15 @@ void Client::stop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint8_t Client::connected() {
|
uint8_t Client::connected() {
|
||||||
|
if (!_connected) return 0;
|
||||||
|
|
||||||
uint8_t s = status();
|
uint8_t s = status();
|
||||||
return !(s == SnSR::LISTEN || s == SnSR::CLOSED || s == SnSR::FIN_WAIT ||
|
return !(s == SnSR::LISTEN || s == SnSR::CLOSED || s == SnSR::FIN_WAIT ||
|
||||||
(s == SnSR::CLOSE_WAIT && !available()));
|
(s == SnSR::CLOSE_WAIT && !available()));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t Client::status() {
|
uint8_t Client::status() {
|
||||||
|
if (!_connected) return SnSR::CLOSED;
|
||||||
return W5100.readSnSR(_sock);
|
return W5100.readSnSR(_sock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user