title: Client(1) to Server to Client(2) in Python 3.x (Sockets?)
body: <p>I've been working with a project that involves sending information to a public server (to demonstrate how key-exchange schemes work) and then sending it to a specific client. There is only two clients. </p>
  
  <p>I'm hoping to get pushed in the right direction on how to get information from client(1) to the server, then have the server redirect that information to client(2). I've messed with the code somewhat, getting comfortable with how to send and recieve information from the server, but I have no idea (~2 hours of research so far) how to differentiate clients and send information to specific clients
  My current server code (pretty much unchanged from the <a href="http://docs.python.org/3/library/socketserver.html" rel="nofollow">python3 docs</a>:</p>
  
  <pre><code>import socketserver
  
  class MyTCPHandler(socketserver.BaseRequestHandler):
  """
  The RequestHandler class for our server.
  
  It is instantiated once per connection to the server, and must
  override the handle() method to implement communication to the
  client.
  """
  
  def handle(self):
      # self.request is the TCP socket connected to the client
      self.data = self.request.recv(1024).strip()
      print("{} wrote:".format(self.client_address[0]))
      print(self.data)
      # just send back the same data, but upper-cased
      self.request.sendall(self.data.upper())
  
  if __name__ == "__main__":
      HOST, PORT = "localhost", 9999
  
  # Create the server, binding to localhost on port 9999
  server = socketserver.TCPServer((HOST, PORT), MyTCPHandler)
  
  # Activate the server; this will keep running until you
  # interrupt the program with Ctrl-C
  server.serve_forever()
  </code></pre>
  
  <p>My client code (pretty much unchanged from the <a href="http://docs.python.org/3/library/socketserver.html" rel="nofollow">python3 docs</a>:</p>
  
  <pre><code>import socket
  import time
  
  data = "matt is ok"
  
  def contactserver(data):
      HOST, PORT = "localhost", 9999
      # Create a socket (SOCK_STREAM means a TCP socket)
      sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  
       # Connect to server and send data
      sock.connect((HOST, PORT))
      sock.sendall(bytes(data, "utf-8"))
  
     # Receive data from the server and shut down
      received = str(sock.recv(1024), "utf-8")
      print("Sent:     {}".format(data))
      print("Received: {}".format(received))
      return format(received)
  
  while True:
      k = contactserver('banana')
      time.sleep(1)
  print(k)
  </code></pre>