Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pickle
- import socketserver
- """
- A simple example of a network unpickler
- Very little error checking, no logging
- few comments and not really fully understood
- Doing this is NOT recommended apparently
- """
- class SocketReciever(socketserver.BaseRequestHandler):
- def handle(self):
- stargate = self.request.makefile('rb')
- arrival = pickle.load(stargate)
- print(arrival.spaceship.info())
- print(arrival.planet.info())
- print("Welcome to my world")
- if __name__ == "__main__":
- HOST, PORT = "localhost", 6668
- # Create the server, binding to localhost on port 9999
- server = socketserver.TCPServer((HOST, PORT), SocketReciever)
- # Activate the server; this will keep running until you
- # interrupt the program with Ctrl-C
- server.serve_forever()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement