Permalink
Browse files

Fix the receive of monitor commands

Remove network delay effects and doubled commands
  • Loading branch information...
1 parent 1ae55b3 commit 42508d407eb67a518dde00acae6c2bbf26d040d5 @Scarzy Scarzy committed Apr 14, 2012
Showing with 12 additions and 8 deletions.
  1. +12 −8 bin/monitor
View
@@ -123,14 +123,18 @@ red_mod_coms = {'APPEND':(1,normal),
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST,PORT))
+buff = ""
+
s.sendall('MONITOR\r\n')
while True:
- data = s.recv(16384)
- print 'Rec:', repr(data)
- parts = get_parts(data)
- print parts
- if parts is None:
- continue
- if parts[1].upper() in red_mod_coms:
- red_mod_coms[parts[1].upper()][1](red_mod_coms[parts[1].upper()][0],parts[2:])
+ buff += s.recv(16384)
+ while buff.find("\r\n") > -1:
+ data = buff[0:buff.find("\r\n") + 2]
+ buff = buff[len(data):]
+ print 'Rec:', repr(data)
+ parts = get_parts(data)
+ if parts is None:
+ continue
+ if parts[1].upper() in red_mod_coms:
+ red_mod_coms[parts[1].upper()][1](red_mod_coms[parts[1].upper()][0],parts[2:])

0 comments on commit 42508d4

Please sign in to comment.