python UDPServer
jbgreer at my-deja.com
jbgreer at my-deja.com
Tue Sep 28 19:11:55 EDT 1999
Howdy,
I have been trying to get a simple UDP server
working in Python. I noticed the SocketServer
modules and said, "Gee, that looks handy!"
So I tried the following:
from SocketServer import *
class
abcsRequestHandler(DatagramRequestHandler)
def handle(self):
self.wfile.write("ABC")
if __name__ == '__main__':
abcs = UDPServer(("localhost", 4000), abcsRequestHandler)
abcs.server_forever()
When I save the above to a file (abcs.py) and try:
python abcs.py
I get:
Traceback (innermost last):
File "abcs.py", line 9, in ?
abcs = UDPServer(("localhost", 4000), abcsRequestHandler)
File "/usr/lib/python1.5/SocketServer.py", line
166, in __init__
self.server_activate()
File "/usr/lib/python1.5/SocketServer.py", line
182, in server_activate()
self.socket.listen(self.request_queue_size)
socket.error: (95, 'Operation not supported')
That is, the script comes to a screeching halt
when, in the course of performing the
initialization for a UDPServer, it defaults to the
initialization behaviour (for the most part) of a
TCPServer, which does a listen(). This is a bad
thing(tm) for a UDP socket.
Having finished my preamble, I humbly ask those in
the know: Has anyone gotten UDPServer as
implemented in SocketServer.py to work? How?
I admit I don't know much about python, but I
followed a TCPServer example really expecting this
to work.
I am using Python 1.5.1 on a Linux system (RedHat
6.0, python-1.5.1-10).
Many thanks in advance,
Jim
Sent via Deja.com http://www.deja.com/
Before you buy.
More information about the Python-list
mailing list