当所有 Windows 应用程序尝试使用 TCP 套接字时,我的应用程序会导致错误 - 获取“无法执行套接字上的操作,因为...” (0x2747) 错误
我编写的应用程序运行一段时间后,所有 TCP 通信都停止工作(无法创建新套接字)。创建新套接字会导致“无法执行套接字上的操作,因为系统缺乏足够的缓冲区空间或队列已满”错误。
我在互联网上读到,似乎我导致 Windows 使用所有“临时”端口,但是当我使用“netstat -a”检查时,我没有看到“数百个”打开的套接字。
该应用程序是 TCP 客户端/服务器。
我一直在努力思考可能会导致这个问题的原因,但我真的被困住了...... 有人帮忙吗?
谢谢!
After an application I wrote was running for a while all TCP communication stopped to work (couldn't create new sockets). Creating a new socket cause "An operation on socket could not be performed because the system lacked sufficient buffer space or because a queue was full" error.
I read across the internet that it seems that I caused windows to use all the "ephemeral" ports, but when I check using "netstat -a" I don't see "hundereds" of open sockets.
The application is a TCP client/server.
I've been trying to think over and over what could cause this issue, but I'm really stuck...
Any help from anyone?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
临时端口有一些限制:一次只能有 4000 个从客户端计算机到远程服务的唯一连接 (TIME_WAIT)。
TIME_WAIT通常配置为240秒。
每 240 秒只能有 4000 个连接。
Ephemeral ports have few limitations: can only be 4000 unique connections from a client machine to a remote service at one time (TIME_WAIT).
TIME_WAIT is usually configured to be 240 seconds.
You could have only 4000 connections per 240 second.
您可能已用完所有套接字缓冲区空间。您是否使用大套接字缓冲区?
You may have used up all the socket buffer space. Are you using large socket buffers?