mirror of
https://github.com/thooge/esp32-nmea2000-obp60.git
synced 2025-12-16 07:23:07 +01:00
add keepalive to socket connections
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "GwTcpClient.h"
|
||||
#include <functional>
|
||||
#include <ESPmDNS.h>
|
||||
#include "GwSocketHelper.h"
|
||||
|
||||
class ResolveArgs{
|
||||
public:
|
||||
@@ -72,6 +73,12 @@ void GwTcpClient::startConnection()
|
||||
LOG_DEBUG(GwLog::ERROR,"unable to create socket: %d", errno);
|
||||
return;
|
||||
}
|
||||
if (! GwSocketHelper::setKeepAlive(sockfd,true)){
|
||||
error="unable to set keepalive, nodelay on socket";
|
||||
LOG_DEBUG(GwLog::ERROR,"%s",error.c_str());
|
||||
close(sockfd);
|
||||
return;
|
||||
}
|
||||
fcntl( sockfd, F_SETFL, fcntl( sockfd, F_GETFL, 0 ) | O_NONBLOCK );
|
||||
int res = lwip_connect_r(sockfd, (struct sockaddr*)&serveraddr, sizeof(serveraddr));
|
||||
if (res < 0 ) {
|
||||
|
||||
Reference in New Issue
Block a user