关于winsock keepalive使用的几点疑问(基于TCP)

cpp_crab cpp_crab 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

1、如果是服务端希望检测客户端的非正常掉线,KeepAlive属性是在服务端代码设置(连接建立成功之后)还是在客户端的代码设置呢?或者是两端都要设置?

2、关于结构体
struct tcp_keepalive {
u_long onoff;
u_long keepalivetime;
u_long keepaliveinterval;
};

不是非常明白keepalivetime和keepaliveinterval的含义,英文比较菜,MSDN的解释如下:
The keepalivetime member specifies the timeout, in milliseconds, with no activity until the first keep-alive packet is sent. The keepaliveinterval member specifies the interval, in milliseconds, between when successive keep-alive packets are sent if no acknowledgement is received.

可否认为是没经历keepaliveinterval时间,重新发送一次心跳包,一次成功的心跳包返回后,keepalivetime时间内不再发送心跳包?

3、对于完成端口而言,如果接收到成功的心跳包,GetQueuedCompletionStatus是否会返回呢?如果会返回的话,返回值为TRUE,lpNumberOfBytes 得到的值为0? 如果心跳包确认超时的话,GetQueuedCompletionStatus会得到返回值FALSE?


不知道说清楚了没,希望大家能够帮我解惑一下,不胜感激!

...全文

相关推荐

评论 7
收藏 已收藏
分享
返回顶部
cpp_crab
网络编程 18,356 成员 64,161 内容