import socketserver


class TCPRequestHandler(socketserver.BaseRequestHandler):

    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())
        msg = self.request.recv(1024)
        print (msg.decode("utf-8"))
        self.request.sendall("UALTGER")

if __name__ == "__main__":
    HOST, PORT = "localhost", 9999

    # Create the server, binding to localhost on port 9999
    with socketserver.TCPServer((HOST, PORT), TCPRequestHandler) as server:
        # Activate the server; this will keep running until you
        # interrupt the program with Ctrl-C
        print("I am listening... port " + str(PORT))
        server.serve_forever()

    