连接linux tcp连接失败,linux – tcp连接在高负载下随机失败 川长思鸟来 2022-10-20 12:30 161阅读 0赞 我们的应用程序使用非阻塞套接字使用连接和选择操作(c代码). pusedo代码如下: unsigned int ConnectToServer(struct sockaddr\_in \*pSelfAddr,struct sockaddr\_in \*pDestAddr) \{ int sktConnect = -1; sktConnect = socket(AF\_INET,SOCK\_STREAM,0); if(sktConnect == INVALID\_SOCKET) return -1; fcntl(sktConnect,F\_SETFL,fcntl(sktConnect,F\_GETFL) | O\_NONBLOCK); if(pSelfAddr != 0) \{ if(bind(sktConnect,(const struct sockaddr\*)(void \*)pSelfAddr,sizeof(\*pSelfAddr)) != 0) \{ closesocket(sktConnect); return -1; \} \} errno = 0; int nRc = connect(sktConnect,(const struct sockaddr\*)(void \*)pDestAddr, sizeof(\*pDestAddr)); if(nrC != -1) \{ return sktConnect; \} if(errno != EINPROGRESS) \{ int savedError = errno; closesocket(sktConnect); return -1; \} fd\_set scanSet; FD\_ZERO(&scanSet); FD\_SET(sktConnect,&scanSet); struct timeval waitTime; waitTime.tv\_sec = 2; waitTime.tv\_usec = 0; int tmp; tmp = select(sktConnect +1, (fd\_set\*)0, &scanSet, (fd\_set\*)0,&waitTime); if(tmp == -1 || !FD\_ISSET(sktConnect,&scanSet)) \{ int savedErrorNo = errno; writeLog("Connect %s failed after select, cause %d, error %s",inet\_ntoa(pDestAddr->sin\_addr),savedErrorNo,strerror(savedErrorNo)); closesocket(sktConnect); return -1; \} . . . . .\} 有80个这样的节点,应用程序以循环方式连接到所有对等节点. 在此阶段,某些节点无法连接(api – connect select),错误号为115. In the below logs (of tcpdump output) for success scenario, we can see (SYN, SYN+ACK, ACK) but no entry of even SYN is present for failed node in tcpdump logs. tcpdump日志是: 387937 2012-07-05 07:45:30.646514 10.18.92.173 10.137.165.136 TCP 33728 > 8441 \[SYN\] Seq=0 Ack=0 Win=5792 Len=0 MSS=1460 TSV=1414450402 TSER=912308224 WS=8 387947 2012-07-05 07:45:30.780762 10.137.165.136 10.18.92.173 TCP 8441 > 33728 \[SYN, ACK\] Seq=0 Ack=1 Win=5792 Len=0 MSS=1460 TSV=912309754 TSER=1414450402 WS=8 387948 2012-07-05 07:45:30.780773 10.18.92.173 10.137.165.136 TCP 33728 > 8441 \[ACK\] Seq=1 Ack=1 Win=5888 Len=0 TSV=1414450435 TSER=912309754 All the above three events indicate the success information. 387949 2012-07-05 07:45:30.782652 10.18.92.173 10.137.165.136 TCP 33728 > 8441 \[PSH, ACK\] Seq=1 Ack=1 Win=5888 Len=320 TSV=1414450436 TSER=912309754 387967 2012-07-05 07:45:30.915615 10.137.165.136 10.18.92.173 TCP 8441 > 33728 \[ACK\] Seq=1 Ack=321 Win=6912 Len=0 TSV=912309788 TSER=1414450436 388011 2012-07-05 07:45:31.362712 10.18.92.173 10.137.165.136 TCP 33728 > 8441 \[PSH, ACK\] Seq=321 Ack=1 Win=5888 Len=320 TSV=1414450581 TSER=912309788 388055 2012-07-05 07:45:31.495558 10.137.165.136 10.18.92.173 TCP 8441 > 33728 \[ACK\] Seq=1 Ack=641 Win=7936 Len=0 TSV=912309933 TSER=1414450581 388080 2012-07-05 07:45:31.702336 10.137.165.136 10.18.92.173 TCP 8441 > 33728 \[PSH, ACK\] Seq=1 Ack=641 Win=7936 Len=712 TSV=912309985 TSER=1414450581 388081 2012-07-05 07:45:31.702350 10.18.92.173 10.137.165.136 TCP 33728 > 8441 \[ACK\] Seq=641 Ack=713 Win=7424 Len=0 TSV=1414450666 TSER=912309985 388142 2012-07-05 07:45:32.185612 10.137.165.136 10.18.92.173 TCP 8441 > 33728 \[PSH, ACK\] Seq=713 Ack=641 Win=7936 Len=320 TSV=912310106 TSER=1414450666 388143 2012-07-05 07:45:32.185629 10.18.92.173 10.137.165.136 TCP 33728 > 8441 \[ACK\] Seq=641 Ack=1033 Win=8704 Len=0 TSV=1414450786 TSER=912310106 388169 2012-07-05 07:45:32.362622 10.18.92.173 10.137.165.136 TCP 33728 > 8441 \[PSH, ACK\] Seq=641 Ack=1033 Win=8704 Len=320 TSV=1414450831 TSER=912310106 388212 2012-07-05 07:45:32.494833 10.137.165.136 10.18.92.173 TCP 8441 > 33728 \[ACK\] Seq=1033 Ack=961 Win=9216 Len=0 TSV=912310183 TSER=1414450831 388219 2012-07-05 07:45:32.501613 10.137.165.136 10.18.92.173 TCP 8441 > 33728 \[PSH, ACK\] Seq=1033 Ack=961 Win=9216 Len=356 TSV=912310185 TSER=1414450831 388220 2012-07-05 07:45:32.501624 10.18.92.173 10.137.165.136 TCP 33728 > 8441 \[ACK\] Seq=961 Ack=1389 Win=10240 Len=0 TSV=1414450865 TSER=912310185 应用程序日志通知连接错误(即api – connect select) \[5258: 2012-07-05 07:45:30\]Connect \[10.137.165.136 \[5258: 2012-07-05 07:45:32\]Connect 10.137.165.137 fail after select, cause:115, error Operation now in progress. Check whether remote machine exist and the network is normal or not. \[5258: 2012-07-05 07:45:32\]Connect to server(\[10.137.165.137 成功日志对应tcpdump的前3个条目.并且在tcpdump中没有事件的故障日志 My question is : When client initiates “connect” api for failed case, i am not able to see any event in the tcpdump at client side (even initial SYN). What can be the reason of this randomness.
相关 网络编程问题:TCP客户端连接失败案例 在TCP客户端的连接过程中,可能会遇到连接失败的情况。以下是一个典型的案例: **案例描述:** 1. **客户端程序准备:** 一个简单的Python TCP客户端代码被 本是古典 何须时尚/ 2024年09月10日 05:36/ 0 赞/ 24 阅读
相关 linux查看每个tcp连接内存,Linux查看tcp连接的keepalive情况 netstat -o --wide 输出类似如下: Proto Recv-Q Send-Q Local Address Foreign Address State Time 清疚/ 2023年01月20日 01:59/ 0 赞/ 121 阅读
相关 查看linux tcp 连接命令,linux下2个检查tcp连接的命令 linux下2个检查tcp连接的命令 这篇文章主要介绍了linux下2个检查tcp连接的命令,需要的朋友可以?考下 1 检测web服务器的链接数量及状态: 结果: 12 小鱼儿/ 2023年01月19日 09:59/ 0 赞/ 137 阅读
相关 连接linux tcp连接失败,linux – tcp连接在高负载下随机失败 我们的应用程序使用非阻塞套接字使用连接和选择操作(c代码). pusedo代码如下: unsigned int ConnectToServer(struct sockaddr 川长思鸟来/ 2022年10月20日 12:30/ 0 赞/ 162 阅读
相关 putty 连接linux失败---解决方案 在VMware中安装Ubuntu之后,主机可以ping通虚拟机,想用putty来连接,结果返回: Authentication refused。 如下为解决方案: 港控/mmm°/ 2022年08月18日 02:19/ 0 赞/ 300 阅读
相关 Xshell连接Kali Linux失败问题 首先你要知道kalilinux默认不允许root用户远程登录,因此需要修改以下文件来达到目的: 如果你没有修改文件则会一直是这种情况: ![watermark_type_ 柔光的暖阳◎/ 2022年04月25日 04:32/ 0 赞/ 1146 阅读
相关 linux 查看tcp连接数 netstat -nat|grep -i "80"|wc -l 转载:[https://www.cnblogs.com/felixzh/p/7737160.html] 以你之姓@/ 2022年03月16日 16:18/ 0 赞/ 217 阅读
相关 linux TCP连接失败(不回复SYN,ACK)问题分析 问题现象 在某一台服务器无法访问另一台服务器的https服务,telnet检测端口发现端口无法连接: [root@020113 ~] telnet 192.16 £神魔★判官ぃ/ 2022年01月20日 03:49/ 0 赞/ 2032 阅读
相关 Xftp连接linux提示连接失败 Xftp连接linux提示连接失败 所属专栏: [Linux][] 版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/j 怼烎@/ 2021年12月17日 17:47/ 0 赞/ 811 阅读
还没有评论,来说两句吧...