I am using the XMLSocket() class to send and receive XML content from a java socket program. If I start the flex applicaion before the java app comes online then I get a SecurityErrorEvent.SECURITY_ERROR - which is OK. But I have retry logic in Flex such that it will continue to try and connect (I am using a timer to retry). Trouble is that once I start the java applicaion I still get the same SECURITY_ERROR, even when the socket and policy file are available.
So it would seem that Flex is caching the URL of my XMLSocket() with no policy file, because when it first tryed to load the policy file there was no response. And it never tries to load the policy file again. Even if I try to force it with the Security.loadPolicyFile call it still wont pick it up.
My java program returns the policy file from the XMLSocket directly. Also it seems that if I stop the java program after flex has made the initial connection then the Flex applicaion can recover (so it seems that it is very importaint that flex have the policy file available the first time it is requested, as it gets cached for the life of the Flex runtime thereafter).
Seems like a bug to me... I can work arround this by ensuring the initial connection is OK before I let the user into the applicaion, but I would think Flex could fix this.