Skip to content
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

fix connection reset by peer case #4626

Merged
merged 4 commits into from
Apr 12, 2018
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
2 changes: 1 addition & 1 deletion libraries/ESP8266WiFi/src/WiFiClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ void WiFiClient::stop()

uint8_t WiFiClient::connected()
{
if (!_client)
if (!_client || _client->state() == CLOSED)
return 0;

return _client->state() == ESTABLISHED || available();
Expand Down
16 changes: 8 additions & 8 deletions libraries/ESP8266WiFi/src/include/ClientContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class ClientContext
tcp_setprio(pcb, TCP_PRIO_MIN);
tcp_arg(pcb, this);
tcp_recv(pcb, &_s_recv);
tcp_sent(pcb, &_s_sent);
tcp_sent(pcb, &_s_acked);
tcp_err(pcb, &_s_error);
tcp_poll(pcb, &_s_poll, 1);

Expand All @@ -58,7 +58,7 @@ class ClientContext
tcp_err(_pcb, NULL);
tcp_poll(_pcb, NULL, 0);
tcp_abort(_pcb);
_pcb = 0;
_pcb = nullptr;
}
return ERR_ABRT;
}
Expand All @@ -79,7 +79,7 @@ class ClientContext
tcp_abort(_pcb);
err = ERR_ABRT;
}
_pcb = 0;
_pcb = nullptr;
}
return err;
}
Expand Down Expand Up @@ -471,11 +471,11 @@ class ClientContext
}
}

err_t _sent(tcp_pcb* pcb, uint16_t len)
err_t _acked(tcp_pcb* pcb, uint16_t len)
{
(void) pcb;
(void) len;
DEBUGV(":sent %d\r\n", len);
DEBUGV(":ack %d\r\n", len);
_write_some_from_cb();
return ERR_OK;
}
Expand Down Expand Up @@ -536,7 +536,7 @@ class ClientContext
tcp_sent(_pcb, NULL);
tcp_recv(_pcb, NULL);
tcp_err(_pcb, NULL);
_pcb = NULL;
_pcb = nullptr;
_notify_error();
}

Expand Down Expand Up @@ -571,9 +571,9 @@ class ClientContext
return reinterpret_cast<ClientContext*>(arg)->_poll(tpcb);
}

static err_t _s_sent(void *arg, struct tcp_pcb *tpcb, uint16_t len)
static err_t _s_acked(void *arg, struct tcp_pcb *tpcb, uint16_t len)
{
return reinterpret_cast<ClientContext*>(arg)->_sent(tpcb, len);
return reinterpret_cast<ClientContext*>(arg)->_acked(tpcb, len);
}

static err_t _s_connected(void* arg, struct tcp_pcb *pcb, err_t err)
Expand Down