Add setKeepAlive()

This commit is contained in:
Mathieu Carbou
2024-04-27 01:17:55 +02:00
parent 46a1dce19f
commit db8cfa1ee7
2 changed files with 14 additions and 0 deletions
+12
View File
@@ -1118,6 +1118,18 @@ bool AsyncClient::getNoDelay(){
return tcp_nagle_disabled(_pcb);
}
void AsyncClient::setKeepAlive(uint32_t ms, uint8_t cnt){
if(ms!=0) {
_pcb->so_options |= SOF_KEEPALIVE; //Turn on TCP Keepalive for the given pcb
// Set the time between keepalive messages in milli-seconds
_pcb->keep_idle = ms;
_pcb->keep_intvl = ms;
_pcb->keep_cnt = cnt; //The number of unanswered probes required to force closure of the socket
} else {
_pcb->so_options &= ~SOF_KEEPALIVE; //Turn off TCP Keepalive for the given pcb
}
}
uint16_t AsyncClient::getMss(){
if(!_pcb) {
return 0;
+2
View File
@@ -135,6 +135,8 @@ class AsyncClient {
void setNoDelay(bool nodelay);
bool getNoDelay();
void setKeepAlive(uint32_t ms, uint8_t cnt);
uint32_t getRemoteAddress();
uint16_t getRemotePort();
uint32_t getLocalAddress();