Call To Socket Throws Error 10093
Contents |
Studio 2015 products Visual Studio Team Services Visual Studio Code Visual Studio Dev Essentials Office Office Word/Excel/PowerPoint Microsoft Graph Outlook OneDrive/Sharepoint Skype Services Store Cortana Bing Application Insights Languages & platforms Xamarin ASP.NET C++ TypeScript socket error 10038 .NET - VB, C#, F# Server Windows Server SQL Server BizTalk Server SharePoint
What Is A Socket Error
Dynamics Programs & communities Students Startups Forums MSDN Subscriber downloads Sign in Search Microsoft Search Windows Dev Center Windows Dev Center
Socket Error Codes Linux
Explore What’s new for Windows 10 Intro to Universal Windows Platform Coding challenges Develop for accessibility Build for enterprise Windows Store opportunities Docs Windows apps Get started Design and UI Develop API reference Publish
Socket Error 10054 Connection Reset By Peer
Monetize Promote Games Get started UI design Develop Publish Desktop Get started Design Develop API reference Test and deploy Compatibility Windows IoT Microsoft Edge Windows Holographic Downloads Samples Support Why Windows Dashboard Explore What’s new for Windows 10 Intro to Universal Windows Platform Coding challenges Develop for accessibility Build for enterprise Windows Store opportunities Docs Windows apps Get started Design and UI Develop API reference Publish Monetize Promote socket error 10053 Games Get started UI design Develop Publish Desktop Get started Design Develop API reference Test and deploy Compatibility Windows IoT Microsoft Edge Windows Holographic Downloads Samples Support Why Windows Dashboard Networking and Internet Windows Sockets 2 Winsock Reference Winsock Reference Windows Sockets Error Codes Windows Sockets Error Codes Windows Sockets Error Codes Socket Options Winsock IOCTLs Winsock Annexes Winsock Enumerations Winsock Functions Winsock Structures and Typedefs Winsock Tracing Events Winsock SPI Windows Sockets Error Codes TOC Collapse the table of content Expand the table of content This documentation is archived and is not being maintained. This documentation is archived and is not being maintained. Windows Sockets Error Codes Most Windows Sockets 2 functions do not return the specific cause of an error when the function returns. For information, see the Handling Winsock Errors topic. The WSAGetLastError function returns the last error that occurred for the calling thread. When a particular Windows Sockets function indicates an error has occurred, this function should be called immediately to retrieve the extended error code for the failing function call. These error codes and a short text description associated with an error code are defined in the Winerror.h header file. The FormatMessage function can be used to
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company socket error 10049 Business Learn more about hiring developers or posting ads with us Stack Overflow Questions socket error 11004 Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million windows 10 socket error programmers, just like you, helping each other. Join them; it only takes a minute: Sign up C++ Winsock 10093 error up vote 1 down vote favorite I'm trying to build a server in C++ which can accept https://msdn.microsoft.com/en-us/library/windows/desktop/ms740668(v=vs.85).aspx multiple number of clients. For that purpose I built a winsock wrapper and using threading with boost for communication for each clients. I encountered a strange problem when trying to accept clients, I have a loop that looks like this. int clientID = 0; listenSocket = new Socket(SocketType::TCP); listenSocket->Bind(port); listenSocket->Listen(); while(running) { Socket *socket = &listenSocket->Accept(); mutex.lock(); clients.push_back(new Client(socket, clientID)); mutex.unlock(); std::cout << "Client with id " << clientID << " connected!" << std::endl; http://stackoverflow.com/questions/16477148/c-winsock-10093-error std::cout << WSAGetLastError() << std::endl; clientID++; } Now, the first client accepts fine and the WSAGetLastError() returns 0, but after the first one connected, even if I dont trying to connect another it just keep writing in the console 10093, which means the Accept() in the loop stoppped blocking and for some reason wont accept properly. I read online that this error caused by not calling WSAStartup() but I did called it in the socket's constructor and it did accept in the first time. c++ winsock share|improve this question edited Dec 25 '15 at 21:31 Bo Persson 58.6k1276142 asked May 10 '13 at 7:20 UnTraDe 1,34331634 Are you possibly calling WSACleanup somewhere, like in a destructor? –Retired Ninja May 10 '13 at 7:32 add a comment| 1 Answer 1 active oldest votes up vote 4 down vote accepted 10093 is WSANOTINITIALISED, which means that WSACleanup() has been called more times than WSAStartup() has been called. Based on the code you have provided, it appears that Socket::Accept() is returning a Socket instead of a Socket*. If so, then Accept() is creating a temporary Socket that goes out of scope immediately after Socket *socket is assigned. Chances are that the Socket destructor is calling WSACleanup() when it should not be. Calls to WSAStartup() and WSACleanup() must be balanced
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about http://stackoverflow.com/questions/10150255/winsock2-error-10093-on-recv Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up WinSock2 Error 10093 on recv up vote 0 down vote favorite So I'm building socket error a multithreaded socket library in windows and I'm getting the WSA Not Started error when I call recv, even though I successfully get a client to connect to the server. I also had it working before I threaded it, but I don't know what happened since then. Any help would be appreciated. Spocket.hpp #include