????Linux???????keepalive???????????????????????TCP/IP???磬????????????????????????????????procfs??sysctl??????
????????????漰??keepalive?????????????????????
????tcp_keepalive_time????????????????????????????????ACKs??????????????keepalive??????????????????????????keepalive????????????????????á?
????tcp_keepalive_intvl????????????keepalive?????????????
????tcp_keepalive_probes?????????????????????????ò????????????е??????????????
????????????????????????Linux????????в????????????????
???????????????????
[root@Server3 ~]# cat /proc/sys/net/ipv4/tcp_keepalive_time
7200
[root@Server3 ~]# cat /proc/sys/net/ipv4/tcp_keepalive_intvl
75
[root@Server3 ~]# cat /proc/sys/net/ipv4/tcp_keepalive_probes
9
?????????????????????????????????н??????????????????600??60??20????
????[root@Server3 ~]# echo 600 > /proc/sys/net/ipv4/tcp_keepalive_time
????[root@Server3 ~]# echo 60 > /proc/sys/net/ipv4/tcp_keepalive_intvl
????[root@Server3 ~]# echo 6 > /proc/sys/net/ipv4/tcp_keepalive_probes
????????????????????????????????????????????????????????????????????????????????????????ο?????????????????????????????????????keepalive????????????????????????
??????????????keepalive????
???????????????????????????????setsockopt()??????
????setsockopt()??????????????????????????????????????????????Э?????????????????????????????“????”?????????????????????????????????????????????????н???????????????????????????
?????????setsockopt()??????????
????#include <sys/types.h>
????#include <sys/socket.h>
????int setsockopt(int sock?? int level?? int optname?? const void *optval?? socklen_t optlen);
??????????
????sock??????????????????????????
????level??????????Э???
????optname?????????????????
????optval??????getsockopt()???????????????塣????setsockopt()??????????????????塣
????optlen??????getsockopt()??????????????????????????????????????????????????????setsockopt()????????????
?????????ú???setsockopt()????????????????keepalive???????????s?????socket?????????????????????????socket()???????д?????????level?????????SOL_SOCKET?????????????????????SO_KEEPALIVE??optval???????????????????????????????????????????????????????????????????С??