I created a basic socket program for client servers in Python 2.7.x, and it works absolutely fine on the same network even on different computers, but when I start the server and client on different networks (the server on my network is friends, and the client is mine) it returns no error and continues to wait. I just don’t understand how to debug the code. I use port 80, killing all services on port 80. I also did port forwarding on port 80 on both machines.
My codes are as follows:
client.py
import socket
s = socket.socket()
host = '103.47.59.130'
port = 80
s.connect((host, port))
while True:
print "From Server: ", s.recv(1024)
s.send(raw_input("Client please type: "))
s.close()
server.py
import socket
s = socket.socket()
host = '192.168.0.104'
port = 80
s.bind((host, port))
s.listen(5)
c, addr = s.accept()
print 'Got connection from', addr
while True:
c.send(raw_input("Server please type: "))
print "From Client: ", c.recv(1024)
c.close()
Sometimes it outputs ** From the server: **, but does not send any messages back and forth.
PS: I used to look at Stack Overflow, but I can’t find anything relevant.