开发者

Windows 2003 server socket error 10055

开发者 https://www.devze.com 2023-03-13 13:39 出处:网络
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 St

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 environ开发者_如何学Pythonment.

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.


I think, it's impossible to say mo than:

Error 10055 means that Windows has run out of TCP/IP socket buffers because too many connections are open at once.

http://kbase.pscs.co.uk/index.php?article=93

https://wiki.pscs.co.uk/how_to:10055


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.


 It creates almost 900 threads

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号