mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-19 23:22:16 +03:00
Add API to set the beginning of local ports range for WiFiClient
This commit is contained in:
parent
703cad32f6
commit
49aeb79b05
@ -40,6 +40,8 @@ extern "C"
|
|||||||
#include "include/ClientContext.h"
|
#include "include/ClientContext.h"
|
||||||
#include "c_types.h"
|
#include "c_types.h"
|
||||||
|
|
||||||
|
uint16_t WiFiClient::_localPort = 0;
|
||||||
|
|
||||||
ICACHE_FLASH_ATTR WiFiClient::WiFiClient()
|
ICACHE_FLASH_ATTR WiFiClient::WiFiClient()
|
||||||
: _client(0)
|
: _client(0)
|
||||||
{
|
{
|
||||||
@ -93,6 +95,10 @@ int ICACHE_FLASH_ATTR WiFiClient::connect(IPAddress ip, uint16_t port)
|
|||||||
if (!pcb)
|
if (!pcb)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
if (_localPort > 0) {
|
||||||
|
pcb->local_port = _localPort++;
|
||||||
|
}
|
||||||
|
|
||||||
ip_addr_t addr;
|
ip_addr_t addr;
|
||||||
addr.addr = ip;
|
addr.addr = ip;
|
||||||
tcp_arg(pcb, this);
|
tcp_arg(pcb, this);
|
||||||
|
@ -61,6 +61,7 @@ public:
|
|||||||
uint16_t remotePort();
|
uint16_t remotePort();
|
||||||
bool getNoDelay();
|
bool getNoDelay();
|
||||||
void setNoDelay(bool nodelay);
|
void setNoDelay(bool nodelay);
|
||||||
|
static void setLocalPortStart(uint16_t port) { _localPort = port; }
|
||||||
|
|
||||||
template<typename T> size_t write(T &src){
|
template<typename T> size_t write(T &src){
|
||||||
uint8_t obuf[1460];
|
uint8_t obuf[1460];
|
||||||
@ -97,6 +98,7 @@ private:
|
|||||||
void _err(int8_t err);
|
void _err(int8_t err);
|
||||||
|
|
||||||
ClientContext* _client;
|
ClientContext* _client;
|
||||||
|
static uint16_t _localPort;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user