简体   繁体   English

Winsock连接可以随机失败吗?

[英]Can Winsock connections randomly fail?

I have a blocking client/server connected locally via Winsock. 我有一个通过Winsock在本地连接的受阻客户端/服务器。 The client uses firefox to retrieve data from websites, passing certain data along to the server for extra processing. 客户端使用firefox从网站检索数据,将某些数据传递到服务器以进行额外处理。 The server always responds, and the processing can take anywhere from 1/10th second to a few minutes. 服务器始终响应,处理可能需要从1/10秒到几分钟。 The client has no winsock connection to anything but the server; 除了服务器之外,客户端没有winsock连接; all web data is retrieved to hard-drive via firefox. 所有网络数据都通过firefox检索到硬盘。

This setup works quite well until, seemingly randomly, the client's recv returns -1 (SOCKET_ERROR) with error code 10054 (WSAECONNRESET). 此设置运行良好,直到看似随机,客户端的recv返回-1(SOCKET_ERROR),错误代码10054(WSAECONNRESET)。 This means the server supposedly terminated connection, but the server is actually still waiting to recv as if nothing is wrong. 这意味着服务器应该终止连接,但服务器实际上仍在等待recv,就好像没有错。 The connection has failed in this way as early as 5 minutes in or after working for as long as about an hour and a half. 早在工作或工作约5个小时后,这种连接就失败了大约一个半小时。 The client sends about 10 different types of requests to the server, and failure has occurred on a variety of them. 客户端向服务器发送大约10种不同类型的请求,并且在各种请求上发生了故障。 The frequency of requests is roughly constant, probably an average of 10-15 a minute. 请求的频率大致保持不变,平均每分钟10-15次。 When the connection breaks, neither computer experiences internet problems and remote desktop does not disconnect. 当连接中断时,计算机都不会遇到Internet问题,并且远程桌面不会断开连接。

Initially I thought memory leaks, but after extensive debugging I am reasonably certain no more exist. 最初我认为内存泄漏,但经过大量调试后,我确信不再存在。 Firefox is engaged in considerable HTTP traffic at times, so I thought maybe that could be filling available socket bufferspace or something -- seems doubtful but at this point I'm really not sure. Firefox有时会占用大量HTTP流量,因此我认为这可能是在填充可用的套接字缓冲区空间或某些内容-似乎值得怀疑,但目前我不确定。 So, could it be more memory leaks, maybe a hidden buffer overrun, too much web traffic? 那么,它可能是更多内存泄漏,可能是隐藏的缓冲区溢出,网络流量过多? What is causing my Winsock app to randomly fail? 是什么导致我的Winsock应用程序随机失败?

Sounds like a firewall at work. 听起来像防火墙在工作。

Many firewalls are configured to terminate idle connections (ie open TCP sessions on which no data is transferred for awhile). 许多防火墙配置为终止空闲连接(即打开TCP会话,暂时不会传输数据)。 Especially if it's an HTTP connection, which are typically not persistent. 特别是如果它是HTTP连接,通常不是持久的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM