How to set socket parameter (TCP_KEEPCNT, TCP_KEEPIDLE, TCP_KEEPINTVL) in java or netty?

On C / Linux, it is easy to set a different value for these socket options for each KEEPALIVE tcp connection independently .

TCP_KEEPCNT (since Linux 2.4) The maximum number of TCP test probes must be sent before deleting the connection. This parameter should not be used in code intended for carrying.

TCP_KEEPIDLE (since Linux 2.4) The connection time (in seconds) must remain inactive before TCP starts sending validation tests if the socket option SO_KEEPALIVE has been set in this juice. This parameter should not be used in code intended for carrying.

TCP_KEEPINTVL (since Linux 2.4) Time (in seconds) between individual probes. This parameter should not be used in code intended for carrying.

In netty or java, how to set three socket options for a socket? I know that there is no portable way to solve it, but only on Linux, can I set these socket options?

+4
source share
2 answers

The link provided does not really tell you how to use JNA to implement it. After spending some time searching for SO to find solutions, I wrote my own library. You can find it here .

+3
source

Netty epoll Linux, , .

. EpollChannelOption.

0

Source: https://habr.com/ru/post/1532261/


All Articles