Hi,
I'm trying to build a DNS server in python. It must listen two ports (8007 - client, 8008 - admin). The client only send an URL and receives the respective IP. The admin has permissions to change the DNS table (add, remove,.. doesn't matter to this right now).
So my question is: how do I implement the server listening continuously on the two ports for any eventual request (we can have several clients at the same time but only one admin when he is operating)
my Server with one listening port:
from SocketServer import * from threading import * from string import * import socket
class Server(ForkingMixIn, TCPServer): pass #fork for each client
class Handler(StreamRequestHandler):
def handle(self):
addr = self.request.getpeername()
print 'Got connection from', addr
data=(self.request.recv(1024)).strip()
if data not in dic: #dic -> dictionary with URL:IP
self.wfile.write('0.0.0.0')
else:
self.wfile.write(dic.get(data))
server = Server(('', 8007), Handler)
server.serve_forever()