I am writing a python socket client which
- Send out
message one(e.g. Hello) every 5 seconds andmessage two(e.g. 15 seconds) every 15 seconds - Receive message at any time
I mean to do the send and receive in different thread. However it is still blocking. Does anyone has suggestion?
Thread #1
threading.Thread(target=Thread2, args=(sock)).start()
sock.recv(1024)
Thread #2
def Thread2(sock):
count = 0
while True:
sleep(5)
count = count + 5
sock.send('Hello')
if count % 15 == 0
sock.send('15 seconds')