Python module which simplifies the task of writing network servers.
Questions tagged [socketserver]
357 questions
6
votes
2 answers
Python SocketServer
How can I call shutdown() in a SocketServer after receiving a certain message "exit"? As I know, the call to serve_forever() will block the server.
Thanks!
![](../../users/profiles/288982.webp)
carlosalbertomst
- 505
- 6
- 17
6
votes
1 answer
SocketServer rfile.read() very very slow
I am building an HTTPS proxy which can forward all SSL traffic. It is called a transparent tunneling. Anyway, I have a problem with Python's socketserver. When I called rfile.read(), it takes a very long time to return. Even I used select to make…
![](../../users/profiles/4106736.webp)
Kehan Wang
- 153
- 1
- 8
6
votes
2 answers
Only receiving one byte from socket
I coded a server program using python.
I'm trying to get a string but i got only a character!
How can I receive a string?
def handleclient(connection):
while True:
…
![](../../users/profiles/1799751.webp)
programmer
- 75
- 1
- 3
6
votes
2 answers
is there any pool for ThreadingMixIn and ForkingMixIn for SocketServer?
I was trying to make an http proxy using BaseHttpServer which is based on SocketServer
which got 2 asynchronous Mixins (ThreadingMixIn and ForkingMixIn)
the problem with those two that they work on each request (allocate a new thread or fork a new…
![](../../users/profiles/810282.webp)
Muayyad Alsadi
- 1,288
- 13
- 20
5
votes
3 answers
Adding SSL Support to SocketServer
I have a Server based on ThreadingTCPServer. Now Ii want to add SSL Support to that Server.
Without SSL it works fine but with SSLv3 I cant connect a Client to the Server, it always throws an exception: Error 111 Connection Refused. The error mens…
![](../../users/profiles/1108763.webp)
Pabi
- 651
- 2
- 10
- 18
5
votes
1 answer
Is there a way for BaseRequestHandler classes to be stateful?
Short Question
Using my examples below, is there a Pythonic way to share my_object's actual instance with with the BaseRequestHandler class?
Background
By definition, the BaseRequestHandler class creates a new instance for each request. Because…
![](../../users/profiles/157744.webp)
Adam Lewis
- 6,307
- 6
- 36
- 59
5
votes
3 answers
Looking to emulate the functionality of socat in Python
I need to send a string to a particular port on localhost using python.
I can achieve this by using socat on the command line like such:
cat | socat stdin tcp-connect:127.0.0.1:55559
I don't want to run the…
![](../../users/profiles/6921406.webp)
BlooMeth
- 81
- 1
- 8
5
votes
0 answers
Python SimpleHTTPServer hangs after several requests
I'm writing a simple integration test which consists of the following:
Starting a simple HTTP server which serves up a page to be tested
Starting various different browsers which load this page to confirm that everything works.
I know #2…
![](../../users/profiles/5041437.webp)
Elephantinae
- 51
- 3
5
votes
1 answer
Shutting down gracefully from ThreadingTCPServer
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…
![](../../users/profiles/369401.webp)
Lynn
- 1,013
- 15
- 28
5
votes
1 answer
Python 2 does not handle signals if TCPServer is running in another thread
While playing with standard library i've found a strange difference between python2 and python3. If i try to catch a signal in python2 while TCPServer is running in a different thread the signal does not get handled, but in python3 it does.
Here is…
![](../../users/profiles/257957.webp)
Blin
- 678
- 9
- 18
4
votes
1 answer
Why does this socket connection only allow 1 send and receive?
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…
![](../../users/profiles/157744.webp)
Adam Lewis
- 6,307
- 6
- 36
- 59
4
votes
1 answer
Python SocketServer.TCPServer request
I've been playing around with Python's SocketServer:
#!/usr/bin/python
import SocketServer
class EchoHandler(SocketServer.BaseRequestHandler):
def handle(self):
data=self.request.recv(1024)
self.request.send(data)
HOST, PORT =…
![](../../users/profiles/51197.webp)
Adam Matan
- 107,447
- 124
- 346
- 512
4
votes
0 answers
Socket server crashing in multithreaded program
I have a standard socketserver that looks a bit like:
import time
import socketserver
import threading
import io
class Handler(socketserver.StreamRequestHandler):
def handle(self):
return cache.handle(self.rfile, self.wfile)
class…
![](../../users/profiles/4819449.webp)
FHTMitchell
- 10,157
- 2
- 21
- 39
4
votes
3 answers
TCP-Server over SSL using SocketServer.TCPServer
i want to add ssl-support to an existing TCP-server which is based on the SocketServer.TCPServer class.
So i overrode the default constructor of the TCPServer class and added the ssl.wrap_socket(...)-call:
class…
![](../../users/profiles/373598.webp)
Biggie
- 6,647
- 10
- 30
- 39
4
votes
3 answers
In python, how to get a UDPServer to shutdown itself?
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) …
![](../../users/profiles/387110.webp)
shwartz
- 581
- 2
- 10
- 28