wtorek, 19 stycznia 2010

simple Flash socket policy server using python Twisted

Well I was reading the articles about flashplayer socket policy.

I started wondering how many lines of code will it take to run the server with python and twisted and here it is.

from twisted.internet import reactor
from twisted.internet.protocol import Factory, Protocol

class PolicySocketProtocol(Protocol):
def dataReceived(self, data):

class PolicyFactory(Factory):
def __init__(self):
self.protocol = PolicySocketProtocol;

if __name__ == '__main__':
reactor.listenTCP(843, PolicyFactory(), interface="")

The server is running on localhost to change this simply modify "" to your host name. It's allowing to access on all ports and all domains what is not recommended for known reasons :)