File tree Expand file tree Collapse file tree 2 files changed +15
-9
lines changed Expand file tree Collapse file tree 2 files changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -131,12 +131,17 @@ void EthernetClient::stop() {
131131 disconnect (_sock);
132132 unsigned long start = millis ();
133133
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
136140 delay (1 );
141+ } while (millis () - start < 1000 );
137142
138143 // if it hasn't closed, close it forcefully
139- if (status () != SnSR::CLOSED)
144+ if (s != SnSR::CLOSED)
140145 close (_sock);
141146
142147 EthernetClass::_server_port[_sock] = 0 ;
Original file line number Diff line number Diff line change @@ -54,12 +54,13 @@ EthernetClient EthernetServer::available()
5454
5555 for (int sock = 0 ; sock < MAX_SOCK_NUM; sock++) {
5656 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+ }
6364 }
6465 }
6566 }
You can’t perform that action at this time.
0 commit comments