Socket write does not work on server

Hi there,

This is my first thread, so nice to meet you all Kirupa members !

Let’s get into the problem right ahead.

I am working with flash CS4, compiling AS3 for Flash Player 9. So I use the class flash.net.Socket

The main function is quite simple :


function openSocket(host, port)
{
    socket = new Socket(host, port);
    socket.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
    socket.addEventListener(SecurityErrorEvent.SECURITY_ERROR, SecurityErrorHandler);
    socket.addEventListener(ProgressEvent.SOCKET_DATA, socketDataHandler);
    socket.addEventListener(Event.CONNECT, ConnectHandler);

    var msg = "side=1&num="+num+"&client="+client+"&state=START&
";
    debug.text += msg;
    socket.writeUTFBytes(msg);
    socket.flush();
}

The listeners simply “trace” the event.

I call the function with a given server address (demo.domain.com) and an accessible port (8082).

The server has a policy daemon on port 843 as required for security reasons. The policy file is the following (which is absolutely not secure for now)


<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "/xml/dtds/cross-domain-policy.dtd">

<cross-domain-policy> 

   <!-- This is a master socket policy file -->
   <!-- No other socket policies on the host will be permitted -->
   <site-control permitted-cross-domain-policies="master-only"/>

   <allow-access-from domain="*" to-ports="*" />

</cross-domain-policy>

So, I have a PHP script on the server which accepts connections on port 8082.
Once accepted, it reads the first message and replies according to the message.

When I compile my flash application within CS4 environment, the socket connects and writes perfectly. The PHP script reads and replies a string which is read back by the flash player perfectly. Then the connection is closed and everybody is happy.

The problem comes when I upload the file to a server (actually the same server than the php script : demo.domain.com).

The socket connects, the UTFWriteBytes and the flush do not return any error or security code but… the server does not read anything.

I guess this is a sandbox security problem so the flash app does not allow the php script to read what was written. I added
Security.allowDomain(“demo.domain.com”);
but it does not change anything.

If you want to get the source code (AS3 and PHP), I can post it all.

Anyone has an idea ?

Thanks !
cidisix