Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

10038 socket error

Is there any solution for 10038 server error .i have done coding in c++; the server runs fine 10 to 12 hours but sudenly it gives 10038 socket error

like image 931
SunilRai86 Avatar asked Oct 16 '10 08:10

SunilRai86


People also ask

What does socket error mean?

The client and server can now communicate by writing to or reading from their sockets. A socket error can occur if one or more of the above conditions are not met or something is blocking communication between the client and server (e.g., firewall, anti-virus).

What is a Windows Socket error?

Windows Sockets are an application program interface (API) that allow communication between two systems over a network. Socket errors can be caused by various issues including connectivity problems on the network, client or server computers or due to a firewall, antivirus or a proxy server.

What are the common causes of Socket error 10054?

Cause. Error 10054 occurs when the connection is reset by the peer application, usually due to an incorrect firewall configuration.


2 Answers

Without seeing your code: the symptom you describe sounds like you are leaking memory/resources, i.e. you are forgetting to free/delete objects you are allocating. It could also be a timing issue. I suggest you post your (cut-down) code.

10038 (WSAENOTSOCK): Socket operation on nonsocket. An operation was attempted on something that is not a socket. Either the socket handle parameter did not reference a valid socket, or for select, a member of an fd_set was not valid.

like image 188
Mitch Wheat Avatar answered Oct 20 '22 06:10

Mitch Wheat


I bet you are accessing a socket that you already closed. This is a very common timing bug in WinSock programming - the good news (and bad news, because it's hard to reproduce) is that you are not hitting it very often so it's likely your code does not need much work to make it perfect. I think you should add thread-safe diagnostics that output a string including the socket value (an int, basically) on every open and close, and from anywhere you see this 10038 or other unexpected errors.

If you can add those diagnostics and then set up a stress test that focuses on open and close areas in your program (you may need to strip down the code to a small subset for unit testing of the sockets handling, maybe doing this back-to-back on localhost, or to two LAN-connected machines) then it will likely manifest much more quickly than 10-12 hours and you may find and fix other timing windows along the way. The goal is to try to compress 10-12 hours of 'normal' socket activity into as small a space of time as possible, to really expose any hard-to-detect concurrency problems.

like image 37
Steve Townsend Avatar answered Oct 20 '22 07:10

Steve Townsend