blob: d5e9f325712a96ccff934330d7f4c5789f7737f3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
from socket import socket, SOCK_STREAM
import json
MESSAGE, AUTHENTICATE, RENAME = "message", "authenticate", "rename"
with socket() as sock:
addr = host, port = "localhost", 8080
print(addr)
sock.connect(addr)
for i in range(1000):
print(f"Sending {i} request")
request = {
"type": "message",
"data": f"hello, {i}",
"user": "andrew"
}
sock.sendall(json.dumps(request).encode())
print("Waiting for response")
response = sock.recv(4096).decode()
print(f"Response: {response}")
sock.sendall("exit".encode())
|