title: how to connect to external_ip in python socket programming
body: <p>client.py</p>
  <pre><code>client_socket = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
  
  port = 443
  socket_address = (&lt;external_ip/global ip address&gt;,port)
  print(&quot;Socket Created&quot;)
  
  # connect to server
  client_socket.connect(socket_address)
  print(&quot;Socket Connected&quot;)
  </code></pre>
  <p>server.py</p>
  <pre><code>server_socket = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
  host_name  = socket.gethostname()
  host_ip = socket.gethostbyname(host_name)
  print('HOST IP:',host_ip)
  port = 443
  socket_address = (host_ip,port)
  
  # Socket Bind
  server_socket.bind(socket_address)
  
  # Socket Listen
  server_socket.listen(5)
  print(&quot;LISTENING AT:&quot;,socket_address)
  server_socket.bind(socket_address
  
  while True:
      client_socket,addr = server_socket.accept()
      print('GOT CONNECTION FROM:',addr)
      if client_socket:
          vid = cv2.VideoCapture(1)
          
          while(vid.isOpened()):
              img,frame = vid.read()
              frame = imutils.resize(frame,width=320)
              a = pickle.dumps(frame)
              message = struct.pack(&quot;Q&quot;,len(a))+a
              client_socket.sendall(message)
              
              cv2.imshow('TRANSMITTING VIDEO',frame)
              if cv2.waitKey(1) == '13':
                  client_socket.close()
  </code></pre>
  <p>I am trying to connect to an external IP over a different network but the program takes to long to connect or it refuses to connect. how do I fix this...any suggestions please!</p>