Create handler for socket handler : Socket Error Handle « Network « Python






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

1.Error Handling ExampleError Handling Example
2.Server With Error Handling