10048 Socket Error During Accept Loop
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 socket error codes linux ASP.NET C++ TypeScript .NET - VB, C#, F# Server Windows Server SQL socket error 10038 Server BizTalk Server SharePoint Dynamics Programs & communities Students Startups Forums MSDN Subscriber downloads Sign in Search Microsoft Search Windows
How To Fix Socket Error
Dev Center Windows Dev Center 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 http://www.symantec.com/connect/forums/altiris-75-lots-error-messages Design and UI Develop API reference Publish 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 https://msdn.microsoft.com/en-us/library/windows/desktop/cc150667(v=vs.85).aspx started Design and UI Develop API reference Publish 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 Winsock Reference Socket Options SOL_SOCKET Socket Options SOL_SOCKET Socket Options SO_EXCLUSIVEADDRUSE SO_EXCLUSIVEADDRUSE SO_EXCLUSIVEADDRUSE SO_BSP_STATE SO_CONDITIONAL_ACCEPT SO_EXCLUSIVEADDRUSE SO_KEEPALIVE SO_PORT_SCALABILITY 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. SO_EXCLUSIVEADDRUSE socket option The SO_EXCLUSIVEADDRUSE socket option prevents other sockets from being forcibly bound to the same address and port. Syntax The SO_EXCLUSIVEADDRUSE option prevents other sockets from being forcibly bound to the same address and port, a practice enabled by the SO_REUSEADDR socket option. Such reuse can be executed by malicious applications to disrupt the application. The SO_EXCLUSIVEADDRUSE option is very useful to system services requiring high availability. The following code example illustrates setting this option. C++ Copy #ifndef UNICODE #define UNICODE #endif #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #include
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 Business http://stackoverflow.com/questions/34798318/how-to-reuse-same-socket-in-python-error-10048-10061-etc/34799197 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 How to reuse same socket in Python (error 10048, 10061 etc) up vote 0 down vote favorite I checked many socket questions and socket error I can't find answer how to write this code correctly I want server socket to keep listening and working but if I'll run client more than once on the same active server I keep getting errors. When I tried to modify code I mostly recieved 10048 and 10061 socket errno or Windows UAC error(which was evaded by changing port number from standard 80). I know that I should remove .close or break loop but whatever socket error 10048 else I put there keeps giving me new errors instead. How this code should look like so server could keep listening to new clients? Client # Echo client program import socket host = '192.168.1.3' # The remote host port = 50007 # The same port as used by the server s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((host, port)) s.send('Hello, world') data = s.recv(1024) s.close() print 'Received', repr(data) Server # Echo server program import socket HOST = '' # Symbolic name meaning all available interfaces PORT = 50007 # Arbitrary non-privileged port s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind((HOST, PORT)) s.listen(1) conn, addr = s.accept() print 'Connected by', addr while 1: data = conn.recv(1024) if not data: break conn.send(data) conn.close() Expected output: Connected by ('192.168.1.3', 51019) <- more than once python python-2.7 sockets share|improve this question asked Jan 14 at 19:44 JeremyK 256 add a comment| 1 Answer 1 active oldest votes up vote 2 down vote accepted In the server, you only call accept once so you will never service more than one client request. You could increase the connection request backlog and do your accepts in an outer while: import socket HOST = '' # Symbolic name meaning all available interfaces PORT = 50007 # Arbitrary non-privileged port s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind((HOST, PORT)) s.listen(5) while 1: conn, addr = s.accept() print 'Connected by', addr conn.settimeout(