Create handler for socket handler
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()
Related examples in the same category