python UDPServer
David Fisher
aiki108 at netscape.net
Thu Sep 30 12:59:31 EDT 1999
>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.
You're right. UDPServer should override server_activate(). And in version
1.5.2 is does.
Like this from Lib/SocketServer.py:
class UDPServer(TCPServer):
"""UDP server class."""
socket_type = socket.SOCK_DGRAM
max_packet_size = 8192
def get_request(self):
data, client_addr = self.socket.recvfrom(self.max_packet_size)
return (data, self.socket), client_addr
def server_activate(self):
# No need to call listen() for UDP.
pass
Your code runs fine on my win98/python1.5.2, except that the method is
called serve_forever() not server_forever(). You can edit the UDPServer
class in Lib/SocketServer.py to the above. or upgrade to 1.5.2. On Linux
the file is probably in /usr/lib/Python1.5.
dnf
More information about the Python-list
mailing list