diff options
Diffstat (limited to 'libraries/WiFi/WiFiClient.cpp')
-rw-r--r-- | libraries/WiFi/WiFiClient.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/libraries/WiFi/WiFiClient.cpp b/libraries/WiFi/WiFiClient.cpp index 83c0d10..0b4b6dc 100644 --- a/libraries/WiFi/WiFiClient.cpp +++ b/libraries/WiFi/WiFiClient.cpp @@ -129,13 +129,13 @@ void WiFiClient::stop() { return; ServerDrv::stopClient(_sock); + WiFiClass::_state[_sock] = NA_STATE; - unsigned long start = millis(); - + int count = 0; + // wait maximum 5 secs for the connection to close + while (status() != CLOSED && ++count < 50) + delay(100); - // wait a second for the connection to close - while (status() != CLOSED && millis() - start < 1000) - delay(1); _sock = 255; } @@ -149,7 +149,7 @@ uint8_t WiFiClient::connected() { return !(s == LISTEN || s == CLOSED || s == FIN_WAIT_1 || s == FIN_WAIT_2 || s == TIME_WAIT || s == SYN_SENT || s== SYN_RCVD || - (s == CLOSE_WAIT && !available())); + (s == CLOSE_WAIT)); } } @@ -169,7 +169,7 @@ WiFiClient::operator bool() { uint8_t WiFiClient::getFirstSocket() { for (int i = 0; i < MAX_SOCK_NUM; i++) { - if (WiFiClass::_state[i] == 0) + if (WiFiClass::_state[i] == NA_STATE) { return i; } |