Questions tagged [socketserver]

Python module which simplifies the task of writing network servers.

357 questions
44
votes
15 answers

socket.error: [Errno 10013] An attempt was made to access a socket in a way forbidden by its access permissions

I'm trying to create a custom TCP stack using Python 2.6.5 on Windows 7 to serve valid http page requests on port 80 locally. But, I've run into a snag with what seems like Windows 7 tightened up security. This code worked on Vista. Here's my…
bitcycle
  • 7,094
  • 13
  • 64
  • 116
21
votes
4 answers

With python socketserver how can I pass a variable to the constructor of the handler class

I would like to pass my database connection to the EchoHandler class, however I can't figure out how to do that or access the EchoHandler class at all. class EchoHandler(SocketServer.StreamRequestHandler): def handle(self): print…
Jesse
  • 295
  • 1
  • 3
  • 6
21
votes
7 answers

Shutdown socketserver serve_forever() in one-thread Python application

I know that socketserver has a method shutdown() which causes server to shut down but this only works in multiple threads application since the shutdown needs to be called from different thread than the thread where serve_forever() is running. My…
samuelg0rd0n
  • 890
  • 1
  • 10
  • 23
17
votes
1 answer

SocketServer: getting rid of '[Errno 98] Address already in use'

I've been looking at the documentation for SocketServer. I copied the TCP server code from the documentation and it runs fine. However, I noticed that whenever I ctrl-c'ed out of the program in my terminal, and then tried to run it again, I would…
rafiki_rafi
  • 1,045
  • 1
  • 8
  • 26
16
votes
4 answers

PHP Sockets - Accept multiple connections

I'm trying to create a simple client/server application and thus I am experimenting with sockets in PHP. Now I have a simple client in C# which connects to the server well, but i can only connect one client at once to this server (I found this code…
JapyDooge
  • 261
  • 1
  • 2
  • 3
13
votes
1 answer

Python - BaseHTTPServer.HTTPServer Concurrency & Threading

Is there a way to make BaseHTTPServer.HTTPServer be multi-threaded like SocketServer.ThreadingTCPServer?
Ian
  • 20,207
  • 21
  • 53
  • 96
12
votes
1 answer

Python socket.send() can only send once, then socket.error: [Errno 32] Broken pipe occurred

I'm a newbie in network programming, so please forgive me if this is a dumb question :) I created 1 client and 1 SocketServer.ThreadingMixIn server on Ubuntu 10.04.2 using Python2.7, but it seems like I can only call sock.send() once in client, then…
hencrice
  • 167
  • 1
  • 1
  • 10
10
votes
1 answer

TcpListener: How to listen on specific port on all interfaces?

There are three overloads for constructing a TcpListener: public TcpListener(int port); (obsolete) public TcpListener(IPEndPoint localEP) public TcpListener(IPAddress localaddr, int port) i want to listen on a particular port, but on all available…
Ian Boyd
  • 220,884
  • 228
  • 805
  • 1,125
10
votes
1 answer

(Are there) PERFORMANCE advantages of python socketserver over regular socket object?

thanks for the interesting responses thus far. In light of said responses I have changed my question a bit. guess what I really need to know is, is socketserver as opposed to the straight-up socket library designed to handle both periods of…
jsh
  • 1,971
  • 17
  • 28
10
votes
4 answers

Python SocketServer: sending to multiple clients?

Well, I'm trying to build a small python prgram with a SocketServer that is supposed to send messages it receives to all connected clients. I'm stuck, I don't know how to store clients on the serverside, and I don't know how to send to multiple…
Alex
  • 1,097
  • 3
  • 10
  • 24
8
votes
1 answer

How to write unit test for Python socketserver request handler?

How can I write unit tests for a socketserver request handler? I have tried to use the following code but have encountered a problem: import socketserver, unittest, threading class TestServer(socketserver.ThreadingMixIn, socketserver.TCPServer): …
argentpepper
  • 3,382
  • 1
  • 28
  • 42
8
votes
2 answers

How to create connection timeout with python SocketServer

Good day! I was writen simple server: class SingleTCPHandler(SocketServer.BaseRequestHandler): def handle(self): data = self.request.recv(1024) self.request.close() class SimpleServer(SocketServer.ThreadingMixIn,…
Alexandr Sharamko
  • 107
  • 1
  • 2
  • 7
7
votes
2 answers

Close server socket on quit/crash

I'm learning how to use sockets in python, and quite often when my program crashes or I Ctrl+C the server socket somehow stays listening on the port. This obviously stops the program from listening on that port when it starts back up again, so I…
Matt
  • 10,197
  • 24
  • 77
  • 109
7
votes
3 answers

Meaning of FLAG in socket send and recv

While searching in the Linux manual page, what I have found about the format of send and recv in socket is like below: For send, ssize_t send(int sockfd, const void *buf, size_t len, int flags); For recv, ssize_t recv(int sockfd, void *buf, size_t…
user3751012
  • 493
  • 1
  • 8
  • 19
7
votes
3 answers

Client Socket Connections Being Denied By Server on Windows Host For Small Number (16 < x < 24) of Simulataneous Client Connection Attempts

We are experiencing a problem where our incoming client socket connections to our socket server are being denied when a relatively small number of nodes (16 to 24, but we will need to handle more in the future) are trying to connect…
Burton Samograd
  • 3,504
  • 16
  • 20
1
2 3
23 24