import SocketServer
port = 8000 class myRequestHandler(SocketServer.StreamRequestHandler):
def handle(self):
print "connection from ", self.client_address
self.wfile.write("data")
srvsocket = SocketServer.TCPServer(("", port), myRequestHandler)
print "The socket is listening to port", port
srvsocket.serve_forever()