Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import SocketServer
- import time
- class GreetingHandler(SocketServer.BaseRequestHandler):
- '''
- Class to handle sending a greeting to a client
- '''
- def handle(self):
- '''
- Method to actually handle the greeting
- '''
- print 'Handling the request.'
- data = self.request.recv(1024)
- self.request.sendall('Request received: %s \n' % data)
- def manageServer():
- '''
- Function to manage the running of the server and handling of requests
- '''
- servObj = SocketServer.TCPServer(('localhost',6099), GreetingHandler)
- print 'Starting the server...'
- servObj.serve_forever()
- if __name__ == '__main__':
- manageServer()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement