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
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).
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.
Cause. Error 10054 occurs when the connection is reset by the peer application, usually due to an incorrect firewall configuration.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With