Skip to content

Commit

Permalink
WiFiClient: clean up ClientContext before connecting
Browse files Browse the repository at this point in the history
Fixes #4497
  • Loading branch information
igrr committed Mar 14, 2018
1 parent 3ce888e commit 9a4b072
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion libraries/ESP8266WiFi/src/WiFiClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,11 @@ int WiFiClient::connect(IPAddress ip, uint16_t port)
ip_addr_t addr;
addr.addr = ip;

if (_client)
if (_client) {
stop();
_client->unref();
_client = nullptr;
}

// if the default interface is down, tcp_connect exits early without
// ever calling tcp_err
Expand Down

0 comments on commit 9a4b072

Please sign in to comment.