Skip to content

client: Fix bool operator on init and ongoing use #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/EthernetClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ extern "C" {
#include "EthernetServer.h"
#include "Dns.h"

EthernetClient::EthernetClient() {
EthernetClient::EthernetClient()
:_tcp_client(NULL) {
}

/* Deprecated constructor. Keeps compatibility with W5100 architecture
sketches but sock is ignored. */
EthernetClient::EthernetClient(uint8_t sock) {
EthernetClient::EthernetClient(uint8_t sock)
:_tcp_client(NULL) {
UNUSED(sock);
}

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

EthernetClient::operator bool() {
return _tcp_client != NULL;
return (_tcp_client && (_tcp_client->state != TCP_CLOSING));
}

bool EthernetClient::operator==(const EthernetClient& rhs) {
Expand Down
2 changes: 2 additions & 0 deletions src/EthernetServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ extern "C" {
EthernetServer::EthernetServer(uint16_t port)
{
_port = port;
_tcp_client[MAX_CLIENT] = {};
_tcp_server = {};
}

void EthernetServer::begin()
Expand Down
2 changes: 1 addition & 1 deletion src/EthernetServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public Server {

void accept(void);
public:
EthernetServer(uint16_t);
EthernetServer(uint16_t port = 80);
EthernetClient available();
virtual void begin();
virtual size_t write(uint8_t);
Expand Down