diff options
author | irungentoo <irungentoo@gmail.com> | 2013-06-25 09:19:01 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2013-06-25 09:19:01 -0400 |
commit | c93858110bb17ce35143bae7ba9aa68fac93f46b (patch) | |
tree | cf2df0b4b2af4d829e3583fedc1fe7e30f666a57 /testing/rect.py | |
parent | b9563fd9e27261ef3d48cb82decfa198e61cca86 (diff) |
DHT almost done, started testing. Fixed ADDR compiling problem. No more warnings with GCC and clang.
Diffstat (limited to 'testing/rect.py')
-rw-r--r-- | testing/rect.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/testing/rect.py b/testing/rect.py new file mode 100644 index 00000000..94baeaec --- /dev/null +++ b/testing/rect.py | |||
@@ -0,0 +1,19 @@ | |||
1 | #basic python UDP script | ||
2 | #for testing only | ||
3 | import socket | ||
4 | |||
5 | UDP_IP = "127.0.0.1" | ||
6 | UDP_PORT = 5004 | ||
7 | |||
8 | sock = socket.socket(socket.AF_INET, # Internet | ||
9 | socket.SOCK_DGRAM) # UDP | ||
10 | sock.bind((UDP_IP, UDP_PORT)) | ||
11 | |||
12 | #send ping request to our DHT on localhost. | ||
13 | sock.sendto("0012345678".decode("hex") + "HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH", ('127.0.0.1', 33445)) | ||
14 | |||
15 | #print all packets recieved and respond to ping requests properly | ||
16 | while True: | ||
17 | data, addr = sock.recvfrom(1024) # buffer size is 1024 bytes | ||
18 | print "received message:", data, " From:", addr | ||
19 | sock.sendto("01".decode('hex') + data[1:5] + "HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH", addr) | ||