title: Python - Can't figure out syntax of tcp/udp client using socket module
body: <p>I have been trying to make a client-server system following <a href="https://www.youtube.com/watch?v=XiVVYfgDolU&amp;t=384s" rel="nofollow noreferrer">this tutorial</a> and for some reason when testing it on two different computers the two computers won't connect.</p>
  
  <p>Both the UDP and the TCP code have failed, and I suspect it's because I can't figure out which IP goes to where.</p>
  
  <p>Code for host:</p>
  
  <pre><code>import socket
  
  def main():
      host = 'ip.ip.ip.ip'
      port = 5000
  
      s = socket.socket()
      s.bind((host, port))
  
      s.listen(1)
      c, addr = s.accept()
      print("Connection from: " + str(addr))
  
      while True:
          data = c.recv(1024)
          if not data:
              break
          print("From connected user: " + str(data))
          data = str(data).upper()
          print("Sending " + str(data))
          c.send(data)
      c.close()
  
  if __name__ == '__main__':
      main()
  </code></pre>
  
  <p>Code for client:</p>
  
  <pre><code>import socket
  
  def main():
      host = 'ip.ip.ip.ip'
      port = 5000
  
      s = socket.socket()
      s.connect((host, port))
  
      message = raw_input("-&gt; ")
      while message != 'q':
          s.send(message)
          data = s.recv(1024)
          print("Recived from server: " + str(data))
          message = raw_input("-&gt; ")
      s.close()
  
  if __name__ == '__main__':
      main()
  </code></pre>