diff options
author | Teddy <[email protected]> | 2013-08-24 15:10:50 +0800 |
---|---|---|
committer | Teddy <[email protected]> | 2013-08-24 15:10:50 +0800 |
commit | 6ceda9466b90d1e9ea608bc91f1192d1ddc56af2 (patch) | |
tree | a3022b1437478d42f66dd7f24ce5094e9dda624b /server | |
parent | 9f239db4b690e648db9c3a2df6b0ee7f26edb0c2 (diff) |
ptp revised
Diffstat (limited to 'server')
-rw-r--r-- | server/client.py | 4 | ||||
-rw-r--r-- | server/piztor_server.py | 5 | ||||
-rw-r--r-- | server/ptp.rst | 23 |
3 files changed, 5 insertions, 27 deletions
diff --git a/server/client.py b/server/client.py index 7ab3c0d..15f4bbc 100644 --- a/server/client.py +++ b/server/client.py @@ -7,7 +7,7 @@ from time import sleep def get_hex(data): return "".join([hex(ord(c))[2:].zfill(2) for c in data]) -HOST, PORT = "192.168.1.101", 9990 +HOST, PORT = "localhost", 9990 def gen_auth(username, password): data = pack("!B", 0) @@ -30,7 +30,7 @@ def send(data): sock.sendall(data) print get_hex(data) # print "Client " + str(sys.argv[1]) + ": sent" - sock.shutdown(socket.SHUT_WR) +# sock.shutdown(socket.SHUT_WR) # print "Client " + str(sys.argv[1]) + ": shutdown" received = sock.recv(1024) finally: diff --git a/server/piztor_server.py b/server/piztor_server.py index 603c27c..514f95f 100644 --- a/server/piztor_server.py +++ b/server/piztor_server.py @@ -168,8 +168,9 @@ class PiztorServer(): class GenericHandler(SocketServer.StreamRequestHandler): def handle(self): + print self.piz_srv sock = self.request - sock.settimeout(10) + sock.settimeout(100) # sock.setblocking(0) data = "" try: @@ -229,5 +230,5 @@ class PiztorServer(): if __name__ == "__main__": - ps = PiztorServer("192.168.1.101", 9990) + ps = PiztorServer("localhost", 9990) ps.run() diff --git a/server/ptp.rst b/server/ptp.rst index ef7af57..4092399 100644 --- a/server/ptp.rst +++ b/server/ptp.rst @@ -42,29 +42,6 @@ Piztor Transmission Protocol v0.1 - 0x00 for success - 0x01 for failure -- Message Sending - - - Request - - :: - - +--1b---+------4b------+------4b-----+-----?b-----+ - | 0x01 | SENDER_TOKEN | RECEIVER_ID | MSG_BODY | - +-uchar-+------int-----+-----int-----+------------+ - - - Response - - :: - - +--1b---+---1b---+ - | 0x01 | STATUS | - +-uchar-+--uchar-+ - - ``STATUS`` : - - - 0x00 for success - - 0x01 for invalid token - - Location Update - Request |