2

C/Linux has the following...

TCP_KEEPCNT (since Linux 2.4) The maximum number of keepalive probes TCP should send before dropping the con- nection. This option should not be used in code intended to be portable.

   TCP_KEEPIDLE (since Linux 2.4)
          The time (in seconds) the connection needs to remain idle

before TCP starts send- ing keepalive probes, if the socket option SO_KEEPALIVE has been set on this socket. This option should not be used in code intended to be portable.

   TCP_KEEPINTVL (since Linux 2.4)
          The time (in seconds) between individual keepalive probes.  

This option should not be used in code intended to be portable.

I know there are portability issues with these but is there anyway to alter these in Java on a Socket?

David Mokon Bond
  • 1,576
  • 2
  • 18
  • 42
  • possible duplicate of [How to set socket option (TCP\_KEEPCNT, TCP\_KEEPIDLE, TCP\_KEEPINTVL) in java or netty?](http://stackoverflow.com/questions/22472844/how-to-set-socket-option-tcp-keepcnt-tcp-keepidle-tcp-keepintvl-in-java-or-n) – abligh Jun 11 '15 at 17:58
  • I've marked http://stackoverflow.com/questions/22472844/how-to-set-socket-option-tcp-keepcnt-tcp-keepidle-tcp-keepintvl-in-java-or-n/29062476#29062476 as a duplicate of this (rather than vice versa) as (though I say it myself having written it) the former question has the fuller answer, and some useful other comments on JNA etc. – abligh Jun 11 '15 at 17:59

1 Answers1

2

doesn't look like something you can readily change from Java, a JNA/JNI wrapper around the C api probably your safest bet.

hhafez
  • 38,949
  • 39
  • 113
  • 143