Skip to content

Commit 380c3f5

Browse files
ficetoficeto
ficeto
authored and
ficeto
committed
add TCP_NODELAY control
1 parent 9436222 commit 380c3f5

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

hardware/esp8266com/esp8266/libraries/ESP8266WiFi/src/WiFiServer.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,17 @@ void WiFiServer::begin()
7373
tcp_arg(listen_pcb, (void*) this);
7474
}
7575

76+
void WiFiServer::setNoDelay(bool nodelay){
77+
if(!_pcb) return;
78+
if(nodelay) tcp_nagle_disable(_pcb);
79+
else tcp_nagle_enable(_pcb);
80+
}
81+
82+
bool WiFiServer::getNoDelay(){
83+
if(!_pcb) return false;
84+
return tcp_nagle_disabled(_pcb);
85+
}
86+
7687
extern "C" uint32_t esp_micros_at_task_start();
7788

7889
bool WiFiServer::hasClient(){

hardware/esp8266com/esp8266/libraries/ESP8266WiFi/src/WiFiServer.h

+2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ class WiFiServer : public Server {
4646
WiFiClient available(uint8_t* status = NULL);
4747
bool hasClient();
4848
void begin();
49+
void setNoDelay(bool nodelay);
50+
bool getNoDelay();
4951
virtual size_t write(uint8_t);
5052
virtual size_t write(const uint8_t *buf, size_t size);
5153
uint8_t status();

hardware/esp8266com/esp8266/libraries/ESP8266WiFi/src/include/ClientContext.h

+12-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,18 @@ class ClientContext {
9898
delete this;
9999
}
100100
}
101-
101+
102+
void setNoDelay(bool nodelay){
103+
if(!_pcb) return;
104+
if(nodelay) tcp_nagle_disable(_pcb);
105+
else tcp_nagle_enable(_pcb);
106+
}
107+
108+
bool getNoDelay(){
109+
if(!_pcb) return false;
110+
return tcp_nagle_disabled(_pcb);
111+
}
112+
102113
uint32_t getRemoteAddress() {
103114
if(!_pcb) return 0;
104115

0 commit comments

Comments
 (0)