From feb4e5f801885b4d14d0ebeac7fcf6bc8873b0b6 Mon Sep 17 00:00:00 2001 From: Joel Martin Date: Wed, 31 Mar 2010 18:20:48 -0500 Subject: [PATCH] Simplify ws_echo.py code. --- ws_echo.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/ws_echo.py b/ws_echo.py index 2405fce..9635859 100755 --- a/ws_echo.py +++ b/ws_echo.py @@ -26,7 +26,9 @@ def start_server(port): handshake(csock, tick) print 'handshaken' while True: - interact(csock, tick) + data = csock.recv(255) + print 'got:%s' %(data) + csock.send("\x00 server response %d \xff" % (tick)) tick+=1 except Exception, e: print "Ignoring exception:", e @@ -37,15 +39,10 @@ def handshake(client, tick): _, path, _ = req_lines[0].split(" ") _, origin = req_lines[4].split(" ") _, host = req_lines[3].split(" ") - print "*** got handshake:\n%s" % handshake - print "*** origin: %s, location: ws://%s%s" % (origin, host, path) + #print "*** got handshake:\n%s" % handshake + print "*** client origin: %s, location: ws://%s%s" % (origin, host, path) client.send(server_handshake % (origin, host, path)) -def interact(client, tick): - data = client.recv(255) - print 'got:%s' %(data) - client.send("\x00 server response %d \xff" % (tick)) - if __name__ == '__main__': if len(sys.argv) < 2: print "Usage: %s " % sys.argv[0]