I've been trying to make a sever that multiple clients can connect to but I ran into a problem. I have a list with all the current connected targets and I want to check if they're still alive without having to manually connect to them.
This is the listener method from the Class I've written:
def listenForConnections(self):
self.s.bind((self.HOST, self.PORT))
while True:
self.s.listen(128)
c, addr = self.s.accept()
self.c = c
print("\n[+]Got a new connection!")
self.conns.append(c)
As you can see, it appends a new connection object to a list from which you then can select a target with a getTarget() method from the same class but I won't paste it here since you probably know how it looks like. Keep in mind that the listener runs in a separate thread. Now I would like to write a ping() function of a sort, that checks every couple of seconds, if all the connections in the conns list are still alive but I have no idea how to do it. I thought in the ping method I would have to send some data to the client every couple of seconds but I fear that it would break the whole program because it could be that the client think that it's a valid command sent from the user and not some garbage to check if a connection is alive or not.