-
-
Notifications
You must be signed in to change notification settings - Fork 214
enforcing stop() when calling connect a second time #949
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,14 +80,8 @@ void arduino::MbedClient::configureSocket(Socket *_s) { | |
} | ||
|
||
int arduino::MbedClient::connect(SocketAddress socketAddress) { | ||
|
||
|
||
if (sock && reader_th) { | ||
// trying to reuse a connection, let's call stop() to cleanup the state | ||
char c; | ||
if (sock->recv(&c, 1) < 0) { | ||
stop(); | ||
} | ||
} | ||
// if a connection is aready ongoing, a disconnection must be enforced before starting another one | ||
stop(); | ||
|
||
|
||
if (sock == nullptr) { | ||
sock = new TCPSocket(); | ||
|
@@ -135,6 +129,9 @@ int arduino::MbedClient::connect(const char *host, uint16_t port) { | |
} | ||
|
||
int arduino::MbedClient::connectSSL(SocketAddress socketAddress) { | ||
// if a connection is aready ongoing, a disconnection must be enforced before starting another one | ||
stop(); | ||
|
||
if (sock == nullptr) { | ||
sock = new TLSSocket(); | ||
_own_socket = true; | ||
|