title: Python client and server chat
body: <p>I am trying to implement a very basic client and server chat in Python though having some trouble, the response I get is that I can only run the client or the server not both at the same time so I can't chat.</p>
  
  <p>Client code:</p>
  
  <pre><code>#client
  import socket
  import time
  
  HOST = "localhost"
  PORT = 5454
  s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  s.bind((HOST,PORT))
  while True:
  
        data = raw_input("Enter..... ")
        s.sendto(data,(Host,PORT))
  
        print "Server says: " + s.recv(1024)
  
        if data=="bye" or s.recv(1024)=="bye":
             print "Exiting..........."
             time.sleep(1)
             break
  </code></pre>
  
  <p>Server code:</p>
  
  <pre><code>#server
  import socket
  import time
  
  HOST = "localhost"
  PORT = 5454
  s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  s.bind((HOST,PORT))
  while True:
  
        print "Client says: " + s.recv(1024)
  
        data = raw_input("Enter..... ")  
        s.sendto(data,(HOST, PORT))
  
        if data=="bye" or s.recv(1024)=="bye":
             print "Exiting.................."
             time.sleep(1)
             break
  </code></pre>
  
  <p>Also does the PORT automatically close after the program closes or do I need to manually close the PORT somehow.</p>