Initial version

This commit is contained in:
Eden Kirin
2023-08-11 09:32:11 +02:00
commit 239a7f825a
3 changed files with 85 additions and 0 deletions

33
client.py Normal file
View File

@ -0,0 +1,33 @@
import socket
import uuid
HOST = "127.0.0.1"
PORT = 10000
def main():
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((HOST, PORT))
n = 0
client_uuid = uuid.uuid4()
try:
while True:
message = f"[{client_uuid}] Hello world from client: {n}"
sock.send(message.encode("ascii"))
rx_data = sock.recv(1024)
print(f"RX: {rx_data.decode('ascii')}")
n += 1
except ConnectionError:
pass
sock.close()
if __name__ == "__main__":
main()