I want to connect two PCs, but when one of the PCs is not on I get an exception that the connection was refused, because the other PC isn't on, so I thought that when this exception happens I just re-execute this part until it succeeds, so when the other PC turns on.
This is what I have:
def main():
s = socket.socket()
host = "Alex-PC"
port = 8080
s.connect((host,port))
if traceback.format_exception(ConnectionRefusedError):
main()
I thought that an if
statement might work, but I have no idea how to write the if
statement for this problem.