title: python socket server over internet
body: <p>So i would like to create a small online game. (I am a complete noob with networking)</p>
  
  <p>I got a server-client connection going if they are both on the same network but would need to do it over the internet. How do i do this?</p>
  
  <p>server.py</p>
  
  <pre><code>import socket
  
  s = socket.socket()
  host = "0.0.0.0"
  port = 5000
  s.bind((host,port))
  s.listen(5)
  while True:
      c, addr = s.accept()
      print("Connection from", addr)
      c.close()
  </code></pre>
  
  <p>client.py</p>
  
  <pre><code>import socket
  
  s = socket.socket()
  host = "192.168.1.66"
  port = 5000
  s.connect((host, port))
  s.send(bytearray("Message", "ascii"))
  </code></pre>
  
  <p>I have tried using my public IP but i cannot connect.</p>