关于套接字:Java TCP 选项

Java TCP options

C/Linux 有以下...

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.

1
2
   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.

1
2
   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.

我知道这些存在可移植性问题,但是无论如何在 Java 中的 Socket 上改变这些?


看起来不像是你可以从 Java 中轻易更改的东西,围绕 C api 的 JNA/JNI package器可能是你最安全的选择。