I am trying to connect my client to another client through a server, however while I'm waiting to start up the other client, this socket is closed due to the recv() call do you guys have any ideas on how I can keep the socket open while waiting on the connection from the other side? After the first res call an empty string is returned everytime.
client = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
client.connect((server_ip,server_port))
client.settimeout(CONNECTION_TIMEOUT)
while True:
try:
toSend = #the hello message that contains the connection id
client.send(toSend.encode())
# print("Sent")
res= client.recv(1024)
print(res.decode())
if 'OK' in res.decode():
break
except client.timeout as e:
continue