1

I have a flash client use XMLsocket to connect python server like this:

Security.loadPolicyFile("xmlsocket://*.*.*.*:843");
socket = new XMLSocket();
socket.connect('*.*.*.*', 50000);
socket.send('hello world');

I use this python script to send security file

#security.py
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(('0.0.0.0', 843))

s.listen(5)
print('Start...')

def link(sock, addr):
    print('Accept new connection from %s:%s...' % addr)
    while True:
        data = sock.recv(1024)
        str = data.decode('utf-8')[:22]
        if str=='<policy-file-request/>':
            print('!!!!!!!')
            sock.send(b'<?xml version="1.0"?>')
            sock.send(b'<cross-domain-policy>')
            sock.send(b'<allow-access-from domain="*" to-ports="50000" />')
            sock.send(b'</cross-domain-policy>\0')
            sock.close()
            break
    print('')

while True:
    sock, addr = s.accept()
    t = threading.Thread(target=link, args=(sock, addr))
    t.start()

and use this to receive messages from client:

#server.py
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(('0.0.0.0', 50000))

s.listen(5)
print('Waiting for connection...')

def tcplink(sock, addr):
    print('Accept new connection from %s:%s...' % addr)
    while True:
        data = sock.recv(1024)
        print(data.decode('utf-8'))

while True:
    sock, addr = s.accept()
    t = threading.Thread(target=tcplink, args=(sock, addr))
    t.start()

when these scripts run,security.py outputs:

Start...
Accept new connection from *.*.*.*....
!!!!!!!

but server.py outputs nothing except this:

Waiting for connection...

and the debug of flash outputs nothing neither

it seems flash received security file successfully,but the XMLsocket.connect failed?

Malashenko
  • 11
  • 1

1 Answers1

0

Hard to say what's wrong here but I'd guess there's still a security problem somewhere. Why don't you add event listeners to the socket connection and see if you will get any error messages? Take a look here at the bottom of the page for some event listener examples: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/XMLSocket.html .

And I guess you have already carefully read this, maybe it will give you some hints: http://help.adobe.com/en_US/as3/dev/WS5b3ccc516d4fbf351e63e3d118a9b90204-7c60.html

Philarmon
  • 1,796
  • 1
  • 10
  • 14