From 4b02715a444e2c2d3d43e5a39fd48f98998dbd1b Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Fri, 28 Mar 2014 12:48:14 +0000 Subject: [PATCH] DevIo.pm/TcpServerUtils.pm: TCP KEEPALIVE added, as requested in forum#21022 git-svn-id: https://svn.fhem.de/fhem/trunk@5350 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/DevIo.pm | 3 ++- fhem/FHEM/TcpServerUtils.pm | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/fhem/FHEM/DevIo.pm b/fhem/FHEM/DevIo.pm index 2fd29b50c..cd41d3c91 100644 --- a/fhem/FHEM/DevIo.pm +++ b/fhem/FHEM/DevIo.pm @@ -208,7 +208,8 @@ DevIo_OpenDev($$$) my $timeout = $hash->{TIMEOUT} ? $hash->{TIMEOUT} : 3; my $conn = IO::Socket::INET->new(PeerAddr => $dev, Timeout => $timeout); if($conn) { - delete($hash->{NEXT_OPEN}) + delete($hash->{NEXT_OPEN}); + $conn->setsockopt(SOL_SOCKET, SO_KEEPALIVE, 1) if(defined($conn)); } else { Log3 $name, 3, "Can't connect to $dev: $!" if(!$reopen); diff --git a/fhem/FHEM/TcpServerUtils.pm b/fhem/FHEM/TcpServerUtils.pm index f32f25eec..4513a2596 100644 --- a/fhem/FHEM/TcpServerUtils.pm +++ b/fhem/FHEM/TcpServerUtils.pm @@ -112,6 +112,7 @@ TcpServer_Accept($$) $defs{$cname} = \%nhash; $selectlist{$nhash{NAME}} = \%nhash; + my $ret = $clientinfo[0]->setsockopt(SOL_SOCKET, SO_KEEPALIVE, 1); Log3 $name, 4, "Connection accepted from $nhash{NAME}"; return \%nhash;