summaryrefslogtreecommitdiff
path: root/tests/circuitpython-manual/socketpool/client/host-server.py
diff options
context:
space:
mode:
authorDavePutz <dwputz@gmail.com>2021-02-24 10:09:52 -0600
committerGitHub <noreply@github.com>2021-02-24 10:09:52 -0600
commiteeb89a97b4a8fa25fb38e4a5d5db78c0c3df9b15 (patch)
treee18ea9f61c7930d1f21d72fb69125a0270558038 /tests/circuitpython-manual/socketpool/client/host-server.py
parentcec921f3747beccff10c2d2dfbc237c305083f62 (diff)
parente41137c745af65b6342c7e2d3b09d8930eefedb0 (diff)
Merge pull request #41 from adafruit/main
Update from adafruit main
Diffstat (limited to 'tests/circuitpython-manual/socketpool/client/host-server.py')
-rw-r--r--tests/circuitpython-manual/socketpool/client/host-server.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/circuitpython-manual/socketpool/client/host-server.py b/tests/circuitpython-manual/socketpool/client/host-server.py
new file mode 100644
index 000000000..fd7ceb7f1
--- /dev/null
+++ b/tests/circuitpython-manual/socketpool/client/host-server.py
@@ -0,0 +1,27 @@
+#!/usr/bin/env python3
+import socket
+
+TIMEOUT = 10
+HOST = "192.168.10.179"
+PORT = 5000
+
+print("Create Socket")
+with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
+ s.settimeout(TIMEOUT)
+ s.bind((HOST, PORT))
+ s.listen()
+ print("Accepting connections")
+ while True:
+ try:
+ conn, addr = s.accept()
+ break
+ except BlockingIOError:
+ pass
+
+ with conn:
+ s.settimeout(TIMEOUT)
+ print('Connected by', addr)
+ data = conn.recv(128)
+ print("got: " + str(data))
+ conn.sendall(data)
+ print("sent: " + str(data))