From 4fc034f044e7049c9ee8703b3efe3c0f371f7bbf Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Wed, 23 May 2012 08:46:42 +0200 Subject: [PATCH] Made everything work correctly --- distribution-server/dist-daemon | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/distribution-server/dist-daemon b/distribution-server/dist-daemon index 2d33a62..d3ac4d0 100755 --- a/distribution-server/dist-daemon +++ b/distribution-server/dist-daemon @@ -22,19 +22,9 @@ select_outputs = [] class Client: def __init__(self, connstream): self.stream = connstream - self.readloop() - - def readloop(self): - try: - data = self.stream.read() - - while data: - print data - data = self.stream.read() - except ssl.SSLError, socket.error: - # todo: handle exception, something went wrong with SSL or connection broke - pass + def process_data(self, data): + print "I received %s" % data bindsocket = socket.socket() bindsocket.bind(('0.0.0.0', 9151)) @@ -43,7 +33,7 @@ bindsocket.listen(5) select_inputs = [ bindsocket ] while select_inputs: - readable, writable, exceptional = select.select(select_inputs, select_outputs, select_inputs) + readable, writable, error = select.select(select_inputs, select_outputs, select_inputs) for sock in readable: if sock is bindsocket: @@ -67,8 +57,8 @@ while select_inputs: data = sock.recv(1024) if data: - print sock.fileno() - print sock.read() + cur_client = client_map[sock.fileno()] + cur_client.process_data(data) else: select_inputs = remove_from_list(select_inputs, sock) print "NOTICE: Client disconnected"