add KEEPALIVE to TCP connections
[spider.git] / perl / Msg.pm
index 746878e26e3c0df1288781e5420b35a1fec18be6..f2881c8ff9a947932c926bb1c4f5a0cf9e57fac1 100644 (file)
@@ -364,7 +364,8 @@ sub nolinger
                my ($l, $t) = unpack("ll", $buf);
                dbg("Linger is: $buf = $l $t");
        }
-       setsockopt($conn->{sock}, SOL_SOCKET, SO_LINGER, pack("ll", 0, 0)) or confess "setsockopt: $!";
+       setsockopt($conn->{sock}, SOL_SOCKET, SO_LINGER, pack("ll", 0, 0)) or confess "setsockopt linger: $!";
+       setsockopt($conn->{sock}, SOL_SOCKET, SO_KEEPALIVE, 1) or confess "setsockopt keepalive: $!";
        if (isdbg('sock') && ($buf = getsockopt($conn->{sock}, SOL_SOCKET, SO_LINGER))) {
                my ($l, $t) = unpack("ll", $buf);
                dbg("Linger is: $buf = $l $t");