I finished working on a 2 player game with python-socket While I tested it locally on my computer it worked fine, so I tested the code on my laptop but it didn't work(the client couldn't connect to the host) when the laptop was the client and for some reason, it did when the laptop was the client. I tested it with my friend too but both when he was the host and I was- didnt work.
this is the code for the server:
import socket
import pickle
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
hostName = input('host name(if you are the host write "host"):')
if hostName == "host":
host = True
hostname = socket.gethostname()
s.bind((socket.gethostbyname(hostname), 4242))
print(f"your host name is: {socket.gethostbyname(hostname)}")
s.listen(1)
conn, addr = s.accept()
else:
host = False
s.connect((hostName,4242))
The error says that the client timeout when it tried to s.connect