circuitpython/tests/circuitpython-manual/socketpool/client/cpy-client.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

27 lines
548 B
Python
Raw Normal View History

2021-02-11 17:36:40 -05:00
import wifi
import socketpool
import ssl
import time
TIMEOUT = None
2021-03-15 09:57:36 -04:00
HOST = "192.168.10.179"
2021-02-11 17:36:40 -05:00
PORT = 5000
# Connect to wifi
print("Connecting to wifi")
wifi.radio.connect("mySSID", "myPASS")
pool = socketpool.SocketPool(wifi.radio)
print("Creating Socket")
with pool.socket(pool.AF_INET, pool.SOCK_STREAM) as s:
s.settimeout(TIMEOUT)
print("Connecting")
s.connect((HOST, PORT))
print("Sending")
2021-03-15 09:57:36 -04:00
sent = s.send(b"Hello, world")
2021-02-11 17:36:40 -05:00
print("Receiving")
buff = bytearray(128)
numbytes = s.recv_into(buff)
print(repr(buff))