Advertisement
Guest User

Untitled

a guest
Aug 8th, 2012
865
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. import pickle
  2. import socketserver
  3. """
  4. A simple example of a network unpickler
  5. Very little error checking, no logging
  6. few comments and not really fully understood
  7. Doing this is NOT recommended apparently
  8. """
  9.  
  10. class SocketReciever(socketserver.BaseRequestHandler):
  11.  
  12. def handle(self):
  13. stargate = self.request.makefile('rb')
  14. arrival = pickle.load(stargate)
  15. print(arrival.spaceship.info())
  16. print(arrival.planet.info())
  17. print("Welcome to my world")
  18.  
  19. if __name__ == "__main__":
  20. HOST, PORT = "localhost", 6668
  21.  
  22. # Create the server, binding to localhost on port 9999
  23. server = socketserver.TCPServer((HOST, PORT), SocketReciever)
  24.  
  25. # Activate the server; this will keep running until you
  26. # interrupt the program with Ctrl-C
  27. server.serve_forever()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement