views:

32

answers:

1

I have a Flash browser application that is used as the front end for a game I'm working on. I would like the application to be able to communicate with other instances of the application. Currently it works using URLRequests, reading from a remote PHP page that echos the data in XML. For this to work it must send a request on a specific interval to check for new messages.

I would like to change this method to Sockets instead so that a "connection" can be opened for communication. This is pretty much where I run into trouble. I have found tutorials on setting up a Java Server that runs on my local machine. This works just fine, but I am absolutely unsure how to get this .java file running on a remote server so that client based Flash applications can contact at any time. I currently have a Linux hosting account with GoDaddy but am more than willing to change this if necessary. Also, if there is an alternative to using Java I am all ears.

Thanks in advanced for the help,

Aaron-

A: 

In my experience godaddy hosting was pretty restrictive about this type of thing, leaving long-running processes going indefinitely, or doing anything at all with java. Although, I was using the cheapest hosting available.

After switching to another hosting provider (dreamhost), I was pleasantly surprised to find that I was fully able and allowed to do exactly what you're trying to do, leave a custom java server running and listening on some socket.

The basic steps to try to get this to work would be: 1. Try to log into your hosting account using ssh or something else to get "shell access" in linux. (there may be other ways around this, but if you can at least get this, your life will just be an awful lot easier). 2. Upload the class file(s) of your java server (ideally compiled into a jar file) using ftp or something, so that you can navigate to it in the linux shell. 3. Run the same java command you use to start your java server on your local machine. The classpath argument may use a different delimiter than other operating systems.

IIRC if you add a & at the end of your command line in linux, it will automatically run in the background. It will also stick around even after you log out.

Now, the next problem I ran into was network latency between the client code running in the browser, and my custom server. This depends a lot on the network of your hosting provider, and its location, and I was generally not pleased with any results I got. If this kind of network latency is a real problem for your application, then you will ultimately probably have to use a different, more 'enterprise' solution.

Jake
Thanks a bunch Jake! I actually started a trial with dreamhost and was able to get a simple socket connection setup to test and verify that it would work. It looks like this is going to work for me!
Aaron Hathaway