Windows 2003 服务器套接字错误 10055
我在 Windows 2003 服务器上运行一个非常大的应用程序。它创建了近 900 个线程和一个在套接字上操作的线程。这是我在 Visual Studio 环境下编译的 C++ 应用程序。
经过近 17-20 小时的测试,我在发送数据时收到 10055 套接字错误。 除了这个错误之外,我的应用程序运行良好,没有任何错误或问题。它是一个具有 4 GiB RAM 的四核系统,该应用程序在其所有运行过程中占用大约 30-40% CPU(在所有 4 个 CPU 上)。
这里有人可以帮助我度过这个难关吗?我在谷歌上搜索了有关此错误的几乎所有内容,但找不到与我的案例相关的任何内容。
I was running a very big application on Windows 2003 server. It creates almost 900 threads and a single thread who is operating on a socket. It's a C++ application which I had compiled with Visual Studio environment.
After almost 17-20 hours of testing, I get 10055 socket error while sending the data.
Apart from this error my application runs excellently without any error or issue. It's a quad core system with 4 GiB of RAM and this application occupies around 30-40% CPU (on all 4 CPUs) in all of its running.
Can anyone here help me to pass through this. I had searched almost everything on google regarding this error but could not get anything relevant to my case.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我想,不可能说莫比:
http://kbase.pscs.co.uk/index.php?article=93
https://wiki.pscs.co.uk/how_to:10055
I think, it's impossible to say mo than:
http://kbase.pscs.co.uk/index.php?article=93
https://wiki.pscs.co.uk/how_to:10055
我以前在 IOCP 套接字系统中见过这种症状。我必须限制传出的异步套接字发送,以便不会有太多数据在内核中排队等待在套接字上发送。
尽管错误文本表明这是由于连接数造成的,但这不是我的经验。如果您编写一个紧密循环在单个套接字上执行异步发送,并且没有限制,则可以非常快地实现这一点。
可能 @Len Holgate 需要在这里添加一些内容,他是我解决 Windows 套接字问题的“首选人员”。
I have seen this symptom before in an IOCP socket system. I had to throttle outgoing async socket sends so that not too much data gets queued in the kernel waiting to be sent on the socket.
Although the error text says this happens due to number of connections, that's not my experience. If you write a tight loop doing async sends on a single socket, with no throttling, you can hit this very quickly.
Possibly @Len Holgate has something to add here, he's my "goto guy" for Windows sockets problems.
这部分是你的问题。每个线程可能使用默认的 1MB 堆栈。您开始接近 1 GB 的线程开销。内存不足的可能性很高。使用 IOCP 的全部意义在于,您不必创建“每个连接的线程”。您只需创建多个线程(CPU 数量的 1 倍到 4 倍)来侦听完成端口处理程序,并让每个线程服务不同的请求,以最大限度地提高可扩展性。
我记得读过 Stack Overflow 上链接的一篇文章,其中设置了您为待处理 IOCP 操作发布的缓冲区,以便操作系统不会让内存从物理内存换出到磁盘。当连接计数变高时,您可能会耗尽系统资源。
如果我没记错的话,解决方法是为每个套接字连接发布一个 0 字节缓冲区(或者是 1 字节缓冲区)。当数据到达时,您的完成端口处理程序将返回,这提示您的代码发布更大的缓冲区。如果我能找到链接,我会分享它。
That's partially your problem. Each thread is likely using the default 1MB of stack. You start to approach a GB of thread overhead. Chances of running out of memory are high. The whole point of using IOCP is so that you don't have to create a "thread per connection". You can just create several threads (from 1x - 4x the number of CPUs) to listen on the completion port handler and have each thread service a different request to maximize scalability.
I recall reading an article linked off of Stack Overflow that buffers you post for pending IOCP operations are setup such that the operating system WILL NOT let the memory swap out from physical memory to disk. And then you can run out of system resources when the connection count gets high.
The workaround, if I recall correctly, is to post a 0 byte buffer (or was it a 1 byte buffer) for each socket connection. When data arrives, your completion port handler will return, and that's a hint to your code to post a larger buffer. If I can find the link, I'll share it.