Windows socket error code 10055

9.8k views Asked by At

I've developed an app that uses sockets over windows. It works perfectly but after some time, the internet connection begin to fail and finally I get this error (10055), which means that my app run out of buffer space.

Actually I think I am only using 2 sockets with the code i did by myself, but it's true that I'm using a 3rd party library that I have no idea how it's implemented.

I've read that there are lot of literature about this trouble, so I am not the only that suffers from it, but I cannot realise how to solve it, or at least, by-pass it, because when it fails, it makes my computer to lose internet connection. I've tried it by catching this error and when it occurs, doing a WSACleanup(), WSAStartup() even when it's not the best practise... but my app still get stacked in this error.

Any advice will be pretty much appreciated.

3

There are 3 answers

0
Bill On BEST ANSWER

Usually this happens when you dnt close your socket properly. Make sure you have both shutdown and closesocket when you want to close the socket (http://msdn.microsoft.com/en-us/library/windows/desktop/ms741394(v=vs.85).aspx) From MSDN - "Note To assure that all data is sent and received on a connection, an application should call shutdown before calling closesocket"

Before you bind the socket, you can use SO_REUSEADDR for setsocketopt which will "Allows the socket to be bound to an address that is already in use" (http://msdn.microsoft.com/en-us/library/windows/desktop/ms740476(v=vs.85).aspx)

Finally, look at this blog - http://blogs.technet.com/b/yongrhee/archive/2011/12/19/how-to-troubleshoot-a-handle-leak.aspx

0
zentrunix On

One cause of this error in Windows is the exhaustion of the ephemeral TCP ports pool.

It's easy to reproduce this error: just create a program that loops in binding port 0. Very soon this error will happen.

When we pass a 0 to the bind socket function, Windows chooses an ephemeral port to use.

0
Klas Lindbäck On

You have one or more resource leaks in your application.

Without the code I can only give general recommendations.

I recommend that you run Valgrind or similar tools to help you find the resource leak.

Another way is by reviewing the code. If the leak started recently you can probably find it by reviewing just recent changes.

MSDN has an article on how to locate memory leaks using Visual Studio. (Remember to choose your version of Visual Studio on the linked page).