File tree 2 files changed +15
-9
lines changed
2 files changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -131,12 +131,17 @@ void EthernetClient::stop() {
131
131
disconnect (_sock);
132
132
unsigned long start = millis ();
133
133
134
- // wait a second for the connection to close
135
- while (status () != SnSR::CLOSED && millis () - start < 1000 )
134
+ // wait up to a second for the connection to close
135
+ uint8_t s;
136
+ do {
137
+ s = status ();
138
+ if (s == SnSR::CLOSED)
139
+ break ; // exit the loop
136
140
delay (1 );
141
+ } while (millis () - start < 1000 );
137
142
138
143
// if it hasn't closed, close it forcefully
139
- if (status () != SnSR::CLOSED)
144
+ if (s != SnSR::CLOSED)
140
145
close (_sock);
141
146
142
147
EthernetClass::_server_port[_sock] = 0 ;
Original file line number Diff line number Diff line change @@ -54,12 +54,13 @@ EthernetClient EthernetServer::available()
54
54
55
55
for (int sock = 0 ; sock < MAX_SOCK_NUM; sock++) {
56
56
EthernetClient client (sock);
57
- if (EthernetClass::_server_port[sock] == _port &&
58
- (client.status () == SnSR::ESTABLISHED ||
59
- client.status () == SnSR::CLOSE_WAIT)) {
60
- if (client.available ()) {
61
- // XXX: don't always pick the lowest numbered socket.
62
- return client;
57
+ if (EthernetClass::_server_port[sock] == _port) {
58
+ uint8_t s = client.status ();
59
+ if (s == SnSR::ESTABLISHED || s == SnSR::CLOSE_WAIT) {
60
+ if (client.available ()) {
61
+ // XXX: don't always pick the lowest numbered socket.
62
+ return client;
63
+ }
63
64
}
64
65
}
65
66
}
You can’t perform that action at this time.
0 commit comments