mirror of
https://github.com/0xFEEDC0DE64/arduino-esp32.git
synced 2025-07-02 21:41:01 +02:00
Remote tcp disconnect not detected (#389)
* Add setNoDelay and getNoDelay to WiFiServer class * Remote TCP disconnect not detected
This commit is contained in:
@ -45,8 +45,11 @@ WiFiClient WiFiServer::available(){
|
||||
int client_sock = accept(sockfd, (struct sockaddr *)&_client, (socklen_t*)&cs);
|
||||
if(client_sock >= 0){
|
||||
int val = 1;
|
||||
if(setsockopt(client_sock, SOL_SOCKET, SO_KEEPALIVE, (char*)&val, sizeof(int)) == ESP_OK)
|
||||
return WiFiClient(client_sock);
|
||||
if(setsockopt(client_sock, SOL_SOCKET, SO_KEEPALIVE, (char*)&val, sizeof(int)) == ESP_OK) {
|
||||
val = _noDelay;
|
||||
if(setsockopt(client_sock, IPPROTO_TCP, TCP_NODELAY, (char*)&val, sizeof(int)) == ESP_OK)
|
||||
return WiFiClient(client_sock);
|
||||
}
|
||||
}
|
||||
return WiFiClient();
|
||||
}
|
||||
@ -69,6 +72,14 @@ void WiFiServer::begin(){
|
||||
_listening = true;
|
||||
}
|
||||
|
||||
void WiFiServer::setNoDelay(bool nodelay) {
|
||||
_noDelay = nodelay;
|
||||
}
|
||||
|
||||
bool WiFiServer::getNoDelay() {
|
||||
return _noDelay;
|
||||
}
|
||||
|
||||
void WiFiServer::end(){
|
||||
close(sockfd);
|
||||
sockfd = -1;
|
||||
|
Reference in New Issue
Block a user