Skip to content

Instantly share code, notes, and snippets.

@sunng87
Created September 25, 2014 08:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sunng87/e9b5e6e5de67f6dc3558 to your computer and use it in GitHub Desktop.
Save sunng87/e9b5e6e5de67f6dc3558 to your computer and use it in GitHub Desktop.
Flash socket policy file server.
#! /usr/bin/python
import SocketServer
class FlashPolicyHandler(SocketServer.StreamRequestHandler):
timeout = 5
"""
The RequestHandler class for our server.
It is instantiated once per connection to the server, and must
override the handle() method to implement communication to the
client.
"""
def handle(self):
# self.request is the TCP socket connected to the client
self.data = self.request.recv(1024).strip()
if self.data == '<policy-file-request/>':
self.request.sendall('<cross-domain-policy><allow-access-from domain="*" to-ports="*" /></cross-domain-policy>')
self.request.close()
if __name__ == "__main__":
HOST, PORT = "0.0.0.0", 843
SocketServer.TCPServer.allow_reuse_address = True
# Create the server, binding to localhost on port 9999
server = SocketServer.TCPServer((HOST, PORT), FlashPolicyHandler)
# Activate the server; this will keep running until you
# interrupt the program with Ctrl-C
server.serve_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment