-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestclient.py
More file actions
33 lines (29 loc) · 844 Bytes
/
testclient.py
File metadata and controls
33 lines (29 loc) · 844 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import socket
import logging
import time
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s '
'[%(levelname)s] (%(threadName)-10s) %(message)s',)
def client(string):
HOST, PORT = 'localhost', 12345
# SOCK_STREAM == a TCP socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# sock.setblocking(0) # optional non-blocking
sock.connect((HOST, PORT))
sock.send(string)
reply = sock.recv(16384) # limit reply to 16K
logging.debug(reply)
sock.close()
return reply
if __name__ == "__main__":
client("test bang #1")
time.sleep(1)
client("test bang #2")
time.sleep(1)
client("test bang #3")
time.sleep(1)
client("test bang #4")
time.sleep(1)
client("test bang #5")
time.sleep(1)
client("test bang #6")