python UDPServer

joshua M. Schmidlkofer menion at mindless.com
Wed Sep 29 20:28:15 EDT 1999


We have accomplish UDP success, but we did not use SocketServer.  We
are using raw sockets...  it's really not that hard....

js

jbgreer at my-deja.com wrote:
> 
> 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