Skip to content

Commit 27b579a

Browse files
authored
Merge pull request #17 from TizenTeam/sandbox/rzr/review/master
client: Fix bool operator on init and ongoing use
2 parents a1db02b + a443221 commit 27b579a

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

src/EthernetClient.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ 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
1617
sketches but sock is ignored. */
17-
EthernetClient::EthernetClient(uint8_t sock) {
18+
EthernetClient::EthernetClient(uint8_t sock)
19+
:_tcp_client(NULL) {
1820
UNUSED(sock);
1921
}
2022

@@ -181,7 +183,7 @@ uint8_t EthernetClient::status() {
181183
// EthernetServer::available() as the condition in an if-statement.
182184

183185
EthernetClient::operator bool() {
184-
return _tcp_client != NULL;
186+
return (_tcp_client && (_tcp_client->state != TCP_CLOSING));
185187
}
186188

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

src/EthernetServer.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ extern "C" {
99
EthernetServer::EthernetServer(uint16_t port)
1010
{
1111
_port = port;
12+
_tcp_client[MAX_CLIENT] = {};
13+
_tcp_server = {};
1214
}
1315

1416
void EthernetServer::begin()

src/EthernetServer.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public Server {
1414

1515
void accept(void);
1616
public:
17-
EthernetServer(uint16_t);
17+
EthernetServer(uint16_t port = 80);
1818
EthernetClient available();
1919
virtual void begin();
2020
virtual size_t write(uint8_t);

0 commit comments

Comments
 (0)