Skip to content

Commit f4364f1

Browse files
committed
Adding client for simpleserver from @anecdata
1 parent c5208fb commit f4364f1

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env python3
2+
import socket
3+
import time
4+
5+
print("A simple client for the wiznet5k_simpleserver.py example in this directory")
6+
print("Run this on any device connected to the same network as the server, after editing this script with the correct HOST & PORT\n")
7+
# Or, use any TCP-based client that can easily send 1024 bytes. For example:
8+
# python -c 'print("1234"*256)' | nc 192.168.10.1 50007
9+
10+
11+
# edit host and port to match server
12+
HOST = "192.168.10.1"
13+
PORT = 50007
14+
TIMEOUT = 10
15+
INTERVAL = 5
16+
MAXBUF = 1024
17+
18+
while True:
19+
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
20+
s.settimeout(TIMEOUT)
21+
print(f"Connecting to {HOST}:{PORT}")
22+
s.connect((HOST, PORT))
23+
# wiznet5k_simpleserver.py wants exactly 1024 bytes
24+
size = s.send(b'A5'*512)
25+
print("Sent", size, "bytes")
26+
buf = s.recv(MAXBUF)
27+
print('Received', buf)
28+
s.close()
29+
time.sleep(INTERVAL)

0 commit comments

Comments
 (0)