Skip to content

Commit

Permalink
LocalIP/LocalPort support
Browse files Browse the repository at this point in the history
  • Loading branch information
aalku authored and igrr committed Aug 19, 2015
1 parent 15f64eb commit 3078103
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,22 @@ uint16_t WiFiClient::remotePort()
return _client->getRemotePort();
}

IPAddress WiFiClient::localIP()
{
if (!_client)
return IPAddress(0U);

return IPAddress(_client->getLocalAddress());
}

uint16_t WiFiClient::localPort()
{
if (!_client)
return 0;

return _client->getLocalPort();
}

int8_t WiFiClient::_s_connected(void* arg, void* tpcb, int8_t err)
{
return reinterpret_cast<WiFiClient*>(arg)->_connected(tpcb, err);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ class WiFiClient : public Client, public SList<WiFiClient> {

IPAddress remoteIP();
uint16_t remotePort();
IPAddress localIP();
uint16_t localPort();
bool getNoDelay();
void setNoDelay(bool nodelay);
static void setLocalPortStart(uint16_t port) { _localPort = port; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,18 @@ class ClientContext {
return _pcb->remote_port;
}

uint32_t getLocalAddress() {
if(!_pcb) return 0;

return _pcb->local_ip.addr;
}

uint16_t getLocalPort() {
if(!_pcb) return 0;

return _pcb->local_port;
}

size_t getSize() const {
if(!_rx_buf) return 0;

Expand Down

0 comments on commit 3078103

Please sign in to comment.