> Currently it is a stand-alone Java application, and not on the web at
> all. I wrote it, however, and could transform it into a Servlet, or
> another type of web-based application if that is what is required.
>
> I'm not sure how to connect Flash and Java on a specific port.
I'm not too familiar with Servlets, but my understanding is that
Servlets are run by a web server (perhaps running on port 80, for example),
and responds to HTTP requests.
It looks like the standard way to get Flash to communicate over a socket
is to use the XMLSocket object. See
http://www.macromedia.com/support/flash/action_scripts/actionscript_dictionary/a
ctionscript_dictionary860.html
I would convert the Java application into a server that listens on some
port (e.g. 4000), let the Flash program connect to that socket, and they
could communicate freely. In your case, you just need a String send from
Flash to Java, and then one from Java to Flash, after which you could
disconnect.
As a first step, you should probably write a Java server that just dumps
whatever it receives in a file or to the console, and have your Flash
application connect to it, to see what protocol XMLSocket uses. Based on its
name, it sounds like it'll send an XML message, e.g something like:
<XMLSocketData>
<StringData>Hello world!</StringData>
</XMLSocketData>
And it probably expects a responce in XML as well. See if you can just
get your "dummy" Java server program to talk to the Flash program. Once
you've got the protocol figured out, look into converting your "real" Java
program into a server using the protocol XMLSocket expects.
- Oliver
Daniel Dyer - 27 Jan 2006 23:12 GMT
> It looks like the standard way to get Flash to communicate over a
> socket
> is to use the XMLSocket object.
My current project is a Java server that communicates with Flash clients.
If you want a continuous connection for asynchronous messaging, XML
Sockets is probably the way to go. Flash's support for web-services is
also worth looking into if you just have a request/response model. I
don't know the details though because I am only involved on the Java side.
> As a first step, you should probably write a Java server that just
> dumps
[quoted text clipped - 6 lines]
> <StringData>Hello world!</StringData>
> </XMLSocketData>
You can use pretty much any well-formed XML, it's not a particular
Macromedia XML format that you have to use. You just send XML documents
down the socket, separated by a single null byte ('\u0000' in Java).
Dan.

Signature
Daniel Dyer
http://www.dandyer.co.uk