mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-21 10:26:06 +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 "c_types.h"
|
||||
|
||||
uint16_t WiFiClient::_localPort = 0;
|
||||
|
||||
ICACHE_FLASH_ATTR WiFiClient::WiFiClient()
|
||||
: _client(0)
|
||||
{
|
||||
@ -93,6 +95,10 @@ int ICACHE_FLASH_ATTR WiFiClient::connect(IPAddress ip, uint16_t port)
|
||||
if (!pcb)
|
||||
return 0;
|
||||
|
||||
if (_localPort > 0) {
|
||||
pcb->local_port = _localPort++;
|
||||
}
|
||||
|
||||
ip_addr_t addr;
|
||||
addr.addr = ip;
|
||||
tcp_arg(pcb, this);
|
||||
|
@ -61,6 +61,7 @@ public:
|
||||
uint16_t remotePort();
|
||||
bool getNoDelay();
|
||||
void setNoDelay(bool nodelay);
|
||||
static void setLocalPortStart(uint16_t port) { _localPort = port; }
|
||||
|
||||
template<typename T> size_t write(T &src){
|
||||
uint8_t obuf[1460];
|
||||
@ -97,6 +98,7 @@ private:
|
||||
void _err(int8_t err);
|
||||
|
||||
ClientContext* _client;
|
||||
static uint16_t _localPort;
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user