Initial version
This commit is contained in:
33
client.py
Normal file
33
client.py
Normal 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()
|
||||
Reference in New Issue
Block a user