aboutsummaryrefslogtreecommitdiff
path: root/libraries/WiFi/WiFiClient.cpp
diff options
context:
space:
mode:
authorCristian Maglie <c.maglie@bug.st>2013-04-03 13:51:04 +0200
committerCristian Maglie <c.maglie@bug.st>2013-04-03 13:51:04 +0200
commitee90e68e86dd61d86f5d17b69080338328765b22 (patch)
treee620c0edc2690ab789b665e567910640597aa6fe /libraries/WiFi/WiFiClient.cpp
parent0ecdc5ebc96ad4c7c548c438a03d9ce00679db8b (diff)
parentf50c307be280dc6ece9e70c43b301c1db36291a0 (diff)
Merged 1.0.5
Merge remote-tracking branch 'arduino/master' into ide-1.5.x Conflicts: app/src/processing/app/Base.java build/shared/revisions.txt hardware/arduino/avr/cores/arduino/malloc.c hardware/arduino/cores/arduino/avr-libc/malloc.c hardware/arduino/cores/arduino/malloc.c todo.txt
Diffstat (limited to 'libraries/WiFi/WiFiClient.cpp')
-rw-r--r--libraries/WiFi/WiFiClient.cpp14
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;
}