Bromo Programmer
Bromo Programmer

Reputation: 670

Flex socket and erlang socket communication problem

I'm creating a client-server game. My client is a flex based game, and my server is erlang server. At the beginning, when I test directly my flex client in flash player, I can establish a connection easily to my erlang server through socket connection. And both can exchange data with no problem.

The problem rise when I deploy my flex app at Apache http server, and running it using a browser by calling http://localhost/ ... my flex socket sends message requesting for a crossdomain policy to my erlang server.

So I create an xml message that represent a crossdomain policy, and send it back to my flex app as a response for that request.

Yet still I can't establish any permanent socket connection between my flex client and my erlang server. I know this because I add listener on my flex socket that will modify its internal state to CONNECTED, if a connection between client-server has established.

Upvotes: 0

Views: 632

Answers (2)

duedl0r
duedl0r

Reputation: 9424

The flashplayer restricts your socket usage in several ways. One you already found out :) The other is to specify whether you use the network or not. There is a networking mode and a file system mode (access to the filesystem). You can't have both.

So you should try to compile it with this:

-use-network=true

And yes I know it's a PITA doing socket programming with flash. You should implement every OnErrorXYZ method and print as much information as possible. Using wireshark or a different network sniffer is also a good idea.

Upvotes: 0

Tim
Tim

Reputation: 5421

I haven't experienced the problem but maybe this would help.

The default policy file is named crossdomain.xml and resides at the root directory of the server that is serving the data... You can use the loadPolicyFile() method to access a nondefault policy file.

http://livedocs.adobe.com/flex/3/html/help.html?content=deployingoverview_12.html

A policy file served by an XMLSocket server has the same syntax as any other policy file, except that it must also specify the ports to which access is granted. When a policy file comes from a port lower than 1024, it can grant access to any ports; when a policy file comes from port 1024 or higher, it can grant access only to other ports 1024 and higher.

http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00005403.html

Upvotes: 0

Related Questions