liunx系统下请问TCP_KEEPIDLE基本时间单位是秒还是毫秒呀?如果是毫秒可以吗?

一叶舟troy 发布于 2016/01/18 18:33
阅读 2K+
收藏 0

int keepAlive = 1;    // 0值,开启keepalive属性

int keepIdle = 60;    // 如该连接在60秒内没有任何数据往来,则进行此TCP层的探测

int keepInterval = 5; // 探测发包间隔为5

int keepCount = 3;        // 尝试探测的次数.如果第1次探测包就收到响应了,则后2次的不再发

setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, (void *)&keepAlive, sizeof(keepAlive));

setsockopt(sockfd, SOL_TCP, TCP_KEEPIDLE, (void*)&keepIdle, sizeof(keepIdle));

setsockopt(sockfd, SOL_TCP, TCP_KEEPINTVL, (void *)&keepInterval, sizeof(keepInterval));

setsockopt(sockfd, SOL_TCP, TCP_KEEPCNT, (void *)&keepCount, sizeof(keepCount)

加载中
0
htfy96
htfy96
TCP_KEEPIDLE (since Linux 2.4) The time ( in seconds) the connection needs to remain idle before TCP starts sending 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.
一叶舟troy
一叶舟troy
:smile:
0
一叶舟troy
一叶舟troy

引用来自“htfy96”的评论

TCP_KEEPIDLE (since Linux 2.4) The time ( in seconds) the connection needs to remain idle before TCP starts sending 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.
yes you are  right
OSCHINA
登录后可查看更多优质内容
返回顶部
顶部
返回顶部
顶部