I am developing a Client-Server game, server is developed by Java Socket, client is developed by J2ME and Flash. Now, data transfer between J2ME Client with Server is OK, and we can play the game on mobile. At the same time, we also developed Flash Client to connect with Server and play the game with J2ME Client. When we run Flash Client on Flash Builder Editor, no problem happened about transfer data between Flash Client and Server, but when we released (export project) to test Flash Client on browsers such as IE or FireFox, many problems happened ...

First problem was Flash Client couldn't connect to Server, Server couldn't listens any request connection from Flash Client, but request connection from J2ME Client was still OK. After many hours searching on goolge, we found the solution for this problem. I fixed Server by creating a Thread listens "policy-file-request" on port 843 to respond content XML "policy-file-request" for Flash Client, then Flash Client connected successfully to Server... I thought everything will be OK, but next problem happened...

Second problem was Flash Client just receive only one a message from Server, I guessed Flash Client closed the socket after receiving a message from Server: when Flash Client login Server, it will send a message contains username and pass, Server will check this information, if account is exist, Server will send 3 messages to Flash Client: message 1-> detail information of user, message 2-> number unread messages of user, message 3-> information about newest version to update. Actually, Flash Client just received only one a message, it was message 1, after that it couldn't receive any message...after many hours found solutions on google, I didn't find any solution for the problem... and final, I tried my solutions. I created a Thread on Server to send message PING to client in order to keep connection from closing between Flash Client and Server, but this solution will slow network. I tried another my solution, every when client received a message from Server, Flash Client will send message PING to Server in order to keep connection for next message from Server. This solution is better, but sometime it worked, sometime it didn't work...

I am stuck at this problem ... hope get ideas from everyone, thanks all!