Skip to content

Commit d899527

Browse files
committed
client: Fix bool operator on init and ongoing use
When iterating we make sure client's socket is not closing since _tcp_client remains after close. This was tested on nuleo-f767zi using project webthing-arduino Change-Id: Ie465fe59009c33957dad97f1c70b4dc3af3b2ebe Forwarded: stm32duino#17 Signed-off-by: Philippe Coval <[email protected]>
1 parent a1db02b commit d899527

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/EthernetClient.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ extern "C" {
99
#include "EthernetServer.h"
1010
#include "Dns.h"
1111

12-
EthernetClient::EthernetClient() {
12+
EthernetClient::EthernetClient()
13+
:_tcp_client(NULL) {
1314
}
1415

1516
/* Deprecated constructor. Keeps compatibility with W5100 architecture
@@ -181,7 +182,7 @@ uint8_t EthernetClient::status() {
181182
// EthernetServer::available() as the condition in an if-statement.
182183

183184
EthernetClient::operator bool() {
184-
return _tcp_client != NULL;
185+
return (_tcp_client && (_tcp_client->state != TCP_CLOSING));
185186
}
186187

187188
bool EthernetClient::operator==(const EthernetClient& rhs) {

0 commit comments

Comments
 (0)