1
0
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:
David A. Mellis 2010-08-03 00:42:23 +00:00
parent f6575c64df
commit f5bb3ab541

View File

@ -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);
} }