implementing simple stream processor with sockets
For the benefit of others (because this answer is two years late):

I had to implement a socket solution rapidly to accommodate testing a feature that required them. Ended up using socketserver to simplify the implementation, i.e., only about a dozen lines were needed.

Example below is pretty much straight out of the socket server docs:

""" creates, activates a socket server """
import socketserver

HOST, PORT = "localhost", 9999


class MyTCPHandler(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())


print("Creating the server, binding to localhost on port", PORT)
server = socketserver.TCPServer((HOST, PORT), MyTCPHandler)


def activate_server():
    server.serve_forever()


def stop_server():
    print("Shutting the server on port", PORT)
    server.shutdown()


if __name__ == "__main__":
    activate_server()