diff options
author | Teddy <ted.sybil@gmail.com> | 2013-08-29 14:28:27 +0800 |
---|---|---|
committer | Teddy <ted.sybil@gmail.com> | 2013-08-29 14:28:27 +0800 |
commit | d922c4debc06158fd65a9b3d4e57165ae87e1d1d (patch) | |
tree | cbb02f37d69b29f6311ce131d87ea627b0621516 /server/piztor/ptp_send.py | |
parent | 95c63e2cdc05f687a976e9e87e1f17998c20349b (diff) |
fixed continous data issue && blocking problem in pushing notification
Diffstat (limited to 'server/piztor/ptp_send.py')
-rw-r--r-- | server/piztor/ptp_send.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/server/piztor/ptp_send.py b/server/piztor/ptp_send.py index 7c55f07..745eeb5 100644 --- a/server/piztor/ptp_send.py +++ b/server/piztor/ptp_send.py @@ -25,7 +25,7 @@ class _SectionSize: PADDING = 1 host = "localhost" #"localhost" -port = 2222 +port = 2223 def gen_auth(username, password): length = _SectionSize.LENGTH + \ @@ -234,9 +234,9 @@ def open_push_tunnel(token, username): sock.sendall(data) print get_hex(sock.recv(6)) - length = -1 while True: received = bytes() + length = -1 while True: if len(received) > 4: length, optcode = unpack("!LB", received[:5]) @@ -245,14 +245,14 @@ def open_push_tunnel(token, username): break rd, wr, err = select([sock], [], []) if rd: - buff = sock.recv(4096) + buff = sock.recv(1) if len(buff) == 0: break received += buff else: break - print len(received) + print "received: " + str(len(received)) pl, optcode, fingerprint = unpack("!LB32s", received[:37]) mesg = received[37:-1] - logger.info("Received a push: %s", mesg) - sock.sendall(pack("!LB32s", 37, 0x00, fingerprint)) + logger.info("Received a push: %s", get_hex(mesg)) + sock.sendall(pack("!LB32s", 37, optcode, fingerprint)) |