I have this socat command that is running fine, but when no data is transfered, it is dying after exactly 5 minutes and I don't understand why as I've set it up to send 100 keepalive every 10 seconds after the first 10 seconds. From what I understood of the socat man page, that should keep it alive for 1000s which is 16 minutes. Also, if I try to set keepcnt to 200, I get "setsockopt(7, 6, 6, {200}, 4): Invalid argument" but nowhere on internet could I find what is the max value for that argument so I think I must be missing something very obvious here. Experimenting more with the arguments never changed the timeout value of 5mn. Setting lower value for keepcnt and higher values of keepintvl is accepted but simply has no visible effect.
socat -d -d -d -v pty,link=/tmp/lp1 tcp:192.168.0.5:9100,reuseaddr,keepalive,keepidle=10,keepintvl=10,keepcnt=100
2017/05/31 08:53:01 socat[16065] I This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit. (http://www.openssl.org/)
2017/05/31 08:53:01 socat[16065] I This product includes software written by Tim Hudson (tjh@cryptsoft.com)
2017/05/31 08:53:01 socat[16065] I setting option "symbolic-link" to "/tmp/lp1"
2017/05/31 08:53:01 socat[16065] I openpty({5}, {6}, {"/dev/pts/1"},,) -> 0
2017/05/31 08:53:01 socat[16065] N PTY is /dev/pts/1
2017/05/31 08:53:01 socat[16065] I setting option "so-keepalive" to 1
2017/05/31 08:53:01 socat[16065] I setting option "tcp-keepidle" to 10
2017/05/31 08:53:01 socat[16065] I setting option "tcp-keepintvl" to 10
2017/05/31 08:53:01 socat[16065] I setting option "tcp-keepcnt" to 100
2017/05/31 08:53:01 socat[16065] N opening connection to AF=2 192.168.0.5:9100
2017/05/31 08:53:01 socat[16065] I starting connect loop
2017/05/31 08:53:01 socat[16065] I socket(2, 1, 6) -> 7
2017/05/31 08:53:01 socat[16065] N successfully connected from local address AF=2 192.168.0.4:56482
2017/05/31 08:53:01 socat[16065] I resolved and opened all sock addresses
2017/05/31 08:53:01 socat[16065] N starting data transfer loop with FDs [5,5] and [7,7]
2017/05/31 08:58:01 socat[16065] N socket 2 (fd 7) is at EOF
2017/05/31 08:58:02 socat[16065] I poll timed out (no data within 0.500000 seconds)
2017/05/31 08:58:02 socat[16065] I close(5)
2017/05/31 08:58:02 socat[16065] I shutdown(7, 2)
2017/05/31 08:58:02 socat[16065] N exiting with status 0