title: Socket connection over internet in Python?
body: <p>I have created a basic client server socket program in Python 2.7.x and it is running absolutely fine over the same network even on different machines but when I run server and client on different networks(server on my friend's network while client on mine) it does not return any error and keeps on waiting. I just can't understand how to debug the code. I am using port 80 by killing all the services on port 80. I have also done port forwarding on port 80 on both the machines.</p>
  
  <p>My codes is as follows:</p>
  
  <p><strong>client.py</strong></p>
  
  <pre><code>import socket              
  
  s = socket.socket()        
  host = '103.47.59.130' 
  port = 80               
  
  s.connect((host, port))
  while True: 
      print "From Server: ", s.recv(1024)  #This gets printed after sometime
      s.send(raw_input("Client please type: "))
  
  s.close()                     
  </code></pre>
  
  <p><strong>server.py</strong></p>
  
  <pre><code>import socket               
  
  s = socket.socket()         # Create a socket object
  host = '192.168.0.104'    #private ip address of machine running fedora
  port = 80                
  s.bind((host, port))       
  
  s.listen(5)                
  c, addr = s.accept()       
  print 'Got connection from', addr    #this line never gets printed
  while True:
     c.send(raw_input("Server please type: "))
     print "From Client: ", c.recv(1024)
  
  c.close()                
  </code></pre>
  
  <p>It sometimes output **From Server: ** but doesnot send any message back and forth.</p>
  
  <p><strong>PS:</strong> I have searched on Stack Overflow earlier but I am unable to find anything relevant.</p>