1 # vim: set encoding=utf-8 et sw=4 sts=4 :
7 import dispatcher as dis
8 import udp_server as us
10 def quit(signum, frame):
11 print "Shuting down ..."
14 signal.signal(signal.SIGINT, quit)
15 signal.signal(signal.SIGTERM, quit)
17 server = us.UDPServer(9999)
20 poll.register(server.sock.fileno(), select.POLLIN | select.POLLPRI)
22 d = dis.Dispatcher(dict(
27 def handle_recv(sock):
28 (msg, addr) = sock.recvfrom(65535)
31 except dis.BadRouteError, inst:
32 sock.sendto('Bad route from : ' + inst.cmd + '\n', addr)
33 except dis.CommandNotFoundError, inst:
34 sock.sendto('Command not found : ' + inst.cmd + '\n', addr)
38 handle_recv(server.sock)