Vxworks中TCP服务器端的SO_KEEPALIVE的超时设置
来源:互联网 发布:一直 正在准备windows 编辑:程序博客网 时间:2024/06/07 00:03
这个设置超时时间折腾了我几个小时,真是在尝试中找到的。
首先,我们看一段help里的话,我用的是tornado2.2的。
The ETIMEDOUT timeout can happen in two ways. If the connection is not yet established, the KEEPALIVE timer expires after idling for TCPTV_KEEP_INIT. If the connection is established, the KEEPALIVE timer starts up when there is no traffic for TCPTV_KEEP_IDLE. If no response is received from the peer after sending the KEEPALIVE segmentTCPTV_KEEPCNT times with interval TCPTV_KEEPINTVL, TCP assumes that the connection is invalid. The TCPTV_KEEP_INIT, TCPTV_KEEP_IDLE, TCPTV_KEEPCNT, andTCPTV_KEEPINTVL parameters are defined in the file target/h/netinet/tcp_timer.h.
我们可以见到上面的几个宏很重要的,我们修改也和它们有关。我分了三步修改才成功。
1.我修改vxworks的内核组件:
在 network components-->networking protocols-->core TCP/IP components-->TCPv4中的Params中,修改
TCP_CON_TIMEO_DFLT,TCP_IDLE_TIMEO_DFLT,TCP_MAX_PROBE_DFLT,修改后,实验,发现不成功,结果是
在5分钟后断开,无论我改成多少值。
2.修改tcp_timer.h里的TCPTV_KEEP_IDLE,TCPTV_KEEPCNT,andTCPTV_KEEPINTVL 这几个宏的值,改小之后实验,
仍然不行,依旧是5分钟
3.在tcp_timer.h里发现有这样一段:
#ifndef VIRTUAL_STACK
extern int tcp_keepidle; /* time before keepalive probes begin */
extern int tcp_keepintvl; /* time between keepalive probes */
extern int tcp_maxidle; /* time to drop after starting probes */
#endif
迫于无奈,我便在自己的程序里,修改了它们的值,如下:
tcp_keepidle = 10;
tcp_keepintvl = 20;
tcp_maxidle = 3;
if (setsockopt(x.tcplistenfd,SOL_SOCKET,SO_KEEPALIVE,(char *)&keepalive,sizeof(keepalive))<0)
{
fprintf(stderr,"SO_KEEPALIVE error:%s/n",strerror(errno));
return;
}
发现终于不是5分钟了,也符合目标了。
到这里,终于搞定,感觉要尝试很多,呵呵。
积极学习,大胆假设,加油啊!
- Vxworks中TCP服务器端的SO_KEEPALIVE的超时设置
- Vxworks中TCP服务器端的SO_KEEPALIVE的超时设置
- vxworks下基于select的TCP服务器端设计
- vxworks下基于select的TCP服务器端设计
- 在windows中的SO_KEEPALIVE时间的设置
- linux Socket 中 setsockopt的SO_KEEPALIVE选项
- linux Socket 中 setsockopt的SO_KEEPALIVE选项
- 虚拟机中VxWorks的网络设置
- TCP底层的SO_KEEPALIVE和应用程序的心跳线程
- TCP/IP Socket心跳机制so_keepalive的三个参数详解
- TCP/IP Socket心跳机制so_keepalive的三个参数详解
- 设置linux中tcp默认的20秒connect超时时间
- VC中调用WebService的超时设置
- socket网络编程中常用的SO_KEEPALIVE套接字选项
- vxworks中TCP例子
- android连接服务器端的连接超时问题
- vxWorks(PPC405ep) 与 windows的Tcp通信
- Linux下的TCP/IP Socket心跳机制so_keepalive的三个参数详解
- WebService
- Visual Assist 添加支持*.cu文件
- DSP 由C升级至C++的错误error: symbol referencing errors 解决办法.
- 网络地址转换的类型
- CentOS5下Python-2.5安装——笔记
- Vxworks中TCP服务器端的SO_KEEPALIVE的超时设置
- 系统定义的Notification
- 我们为什么不喜欢招聘培训学校的学生
- 表格的css,细线表格
- Android学习笔记(二十):回归简单的ListView
- 通用的线程池框架
- 向前台页面动态插入用户控件
- asp程序使用FCKeditor上传图片设置【来自互联网】
- CentOS5下mysql源码安装方式——笔记