title: How to connect 2 computers on diffrent networks using python sockets
body: <p>I'm trying to connect 2 different computers that on different networks,
  but I got an error:</p>
  
  <blockquote>
    <p>TimeoutError: [Errno 110] Connection timed out</p>
  </blockquote>
  
  <p>And sometimes I got this error:</p>
  
  <blockquote>
    <p>OSError: [Errno 113] No route to host</p>
  </blockquote>
  
  <p>I wrote the <code>server.py</code> script and started it on the first pc and <code>client.py</code> on the second one.</p>
  
  <p><code>server.py</code></p>
  
  <pre class="lang-py prettyprint-override"><code>import socket
  server_socket = socket.socket()
  server_socket.bind(("127.0.0.1", 80))
  server_socket.listen(1)
  (client_socket, client_address) = server_socket.accept()
  print ("client_connected [" + client_address[0] + "]")
  client_command = client_socket.recv(1024).decode()
  print(client_command.encode())
  </code></pre>
  
  <p><code>client.py</code></p>
  
  <pre class="lang-py prettyprint-override"><code>import socket
  client_socket = socket.socket()
  client_socket.connect(("server_public_ip_here", 8820))
  client_command = input("command: ")
  client_socket.send(client_command.encode())
  data = client_socket.recv(1024).decode()
  print("server: " + data)
  </code></pre>
  
  <p>I expect to get a connections between the computers but keep getting a <code>TimeoutError</code> or <code>OSError</code></p>