1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-19 23:22:16 +03:00

LocalIP/LocalPort support

This commit is contained in:
aalku 2015-08-14 22:27:21 +02:00 committed by Ivan Grokhotkov
parent a2f3637ed4
commit acc34e2914
3 changed files with 30 additions and 0 deletions

View File

@ -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);

View File

@ -60,6 +60,8 @@ public:
IPAddress remoteIP();
uint16_t remotePort();
IPAddress localIP();
uint16_t localPort();
bool getNoDelay();
void setNoDelay(bool nodelay);
static void setLocalPortStart(uint16_t port) { _localPort = port; }

View File

@ -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;