socketserver

Reuse of sockets

ぃ、小莉子 提交于 2019-12-12 06:14:17
问题 I have a simple TCP server using the socketserver library. It used to work fine, but now I get this error message whenever I run it: socket.error: [Errno 10048] Only one usage of each socket address (protocol/network address/port) is normally permitted Here is the code: class Handler(socketserver.StreamRequestHandler): def handle(self): sys.stdout = self.wfile self.data = str(self.request.recv(1024).strip(), "utf-8") exec(self.data, globals()) def handle_error(request, client_address): print(

Multiple client not getting connected and cannot communicate at the same time

╄→гoц情女王★ 提交于 2019-12-12 03:31:27
问题 Below is the server code which I have written for multiple clients. But if I want to connect it with the second client, I am not able to connect it at the same time. At first I need to close the first client and then only I can connect and communicate with the second client. I think I have some problem while using the pthread_join . Not sure what is the exact problem. I want to make the server work for multiple clients at the same time. #include<stdio.h> #include<string.h> //strlen #include

Shutdown for socketserver based Python 3 server hangs

与世无争的帅哥 提交于 2019-12-11 00:25:22
问题 I am working on a "simple" server using a threaded SocketServer in Python 3. I am going through a lot of trouble implementing shutdown for this. The code below I found on the internet and shutdown works initially but stops working after sending a few commands from the client via telnet. Some investigation tells me it hangs in threading._shutdown... threading._wait_for_tstate_lock but so far this does not ring a bell. My research tells me that there are ~42 different solutions, frameworks, etc

In python, how to get a UDPServer to shutdown itself?

会有一股神秘感。 提交于 2019-12-10 08:46:00
问题 I've created a class for a server with the declaration: class myServer(socketserver.BaseRequestHandler): def handle(self): pass And started it with: someServer = socketserver.UDPServer((HOST, PORT), myServer) someServer.serve_forever() My question is: how can I get the server to shutdown itself? I've seen it has a base class (of a base class) called BaseServer with a shutdown method. It can be called on someServer with someServer.shutdown() but this is from the outside of the server itself.

python SocketServer stuck on waitpid() syscall

爷,独闯天下 提交于 2019-12-08 13:34:58
问题 I am using Python (2.7) SocketServer with ForkingMixIn. It worked well. However sometimes on heavy usage (tons of rapidly connecting/disconnecting clients) the "server" stuck, consuming all the idle CPU (shown 100% CPU by top). If I use strace from CLI on the process it shows it does endless sequence of waitpid() syscall. According to command "ps" there are no child processes though at this point. After this problem my server implementation goes unusable and only its restarting helps :(

Is it bad Ju-ju that the port is still being listened to after my app shuts down?

北慕城南 提交于 2019-12-08 12:55:40
问题 My app listens on a certain port for socket messages. I can see that it is LISTENING via "netstat -a" at the command line. When I shut the app down, the machine is still listening on that port when I re-run "netstat -a" Is this a problem? It seems like maybe it is, as when I subsequently start the app again, it crashes ignominiously. How can I cause the listening to cease? using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing;

Socketserver multiprocessing.Process is starting without calling start()

回眸只為那壹抹淺笑 提交于 2019-12-07 21:14:06
问题 I have a problem with a Python script on my rpi. If I create a process object, it starts automatically and blocks everything else. I want it to run in the background, and to be able to start it by calling the start() method. network_manager.py: import socketserver class NetworkManagerHandler(socketserver.StreamRequestHandler): def handle(self): print("Got some Data!") class NetworkManagerServer(socketserver.ForkingMixIn, socketserver.TCPServer): pass core.py: import multiprocessing from

Why does this socket connection only allow 1 send and receive?

蹲街弑〆低调 提交于 2019-12-07 08:01:10
问题 Background I have a simple socket server setup that I am trying to allow simultaneous connections to and echo back the data. The client side launches several threads each making its own connection to the server. This works fine for the socket.send() call, but all subsequent calls cause either a "Connection reset by peer" or a "Broken pipe". Note that I have not found the change that toggles the reset and broken pipe. I have looked here on SO for a solution, but I'm afraid I may not know what

Shutting down gracefully from ThreadingTCPServer

一笑奈何 提交于 2019-12-07 06:16:55
问题 I've created a simple test app (Python 2.6.1) that runs a ThreadingTCPServer, based on the example here. If the client sends a command "bye" I want to shut down the server and exit cleanly from the application. The exit part works OK, but when I try to re-run the app, I get: socket.error: [Errno 48] Address already in use I tried the solution given here for setting the socket options but that didn't seem to help. I've tried various ways to close the server down, but always get the same error.

Shutting down python TCPServer by custom handler

故事扮演 提交于 2019-12-06 11:39:39
I'm trying to shutdown a TCPServer from the SocketServer module through a GET request by the client, emitted when the window is closed, however the following code fails to initiate the shutdown: def show_webgl(data): import SocketServer import SimpleHTTPServer from webbrowser import open PORT = 8000 RUNNING = True class CustomHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): def do_GET(self): if self.path=='/atom.json': # return data return elif self.path == '/shutdown': httpd.shutdown() # quit server, this line is never reached else: # serve other files SimpleHTTPServer