Skip to content

Commit

Permalink
Merge pull request #531 from romainreignier/feature/fill_tcp_client_p…
Browse files Browse the repository at this point in the history
…ort_and_address

MbedClient: retrieve the address and port from the underlying socket …
  • Loading branch information
facchinm authored Aug 2, 2022
2 parents be79090 + 3e293a4 commit a4a950e
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions libraries/SocketWrapper/src/MbedClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ void arduino::MbedClient::setSocket(Socket *_sock) {
void arduino::MbedClient::configureSocket(Socket *_s) {
_s->set_timeout(_timeout);
_s->set_blocking(false);
_s->getpeername(&address);

if (event == nullptr) {
event = new rtos::EventFlags;
Expand Down Expand Up @@ -99,7 +100,6 @@ int arduino::MbedClient::connect(SocketAddress socketAddress) {
return 0;
}

address = socketAddress;
nsapi_error_t returnCode = static_cast<TCPSocket *>(sock)->connect(socketAddress);
int ret = 0;

Expand Down Expand Up @@ -150,8 +150,6 @@ int arduino::MbedClient::connectSSL(SocketAddress socketAddress) {
return 0;
}

address = socketAddress;

restart_connect:
nsapi_error_t returnCode = static_cast<TLSSocket *>(sock)->connect(socketAddress);
int ret = 0;
Expand Down Expand Up @@ -304,7 +302,7 @@ IPAddress arduino::MbedClient::remoteIP() {
}

uint16_t arduino::MbedClient::remotePort() {
return 0;
return address.get_port();
}

void arduino::MbedClient::setTimeout(unsigned long timeout) {
Expand Down

0 comments on commit a4a950e

Please sign in to comment.