views:

133

answers:

3

I wish to create a Java Socket server which can be connected to using Javascript and/or Flash. I have experience in Connecting to sockets in flash, and using a comet like system in Ajax. I wish to make a live communication system, which will intale multiple connections to the server from various clients, needing almost instant communication between peers. I coded a system like this in PHP but I want to convert it to Java, simply because I don't want the PHP engine to be tied up on this Sever, as it serves all the web stuff normally on the site, and i've heard is more powerful for this sort of thing. Just looking for advice on where I can start learning how to write this sort of system using Java? I have previous coding experience in PHP, Javascript, Adobe Air and AS3 if That helps?

+1  A: 

General Sockets:

Sun Sockets Tutorial here

A Framework:

Apache MINA is a network application framework which helps users develop high performance and high scalability network applications easily. It provides an abstract · event-driven · asynchronous API over various transports such as TCP/IP and UDP/IP via Java NIO.

GWT RPC to communicate from JS to Server:

At some point, most GWT applications will need to interact with a backend server. GWT provides a couple of different ways to communicate with a server via HTTP. You can use the GWT RPC framework to transparently make calls to Java servlets and let GWT take care of low-level details like object serialization. Alternatively, you can use GWT's HTTP client classes to build and send custom HTTP requests.

DevGuideServerCommunication

Bakkal
A: 

You may also want to look at servlets since they are one level up from sockets.

Edit: Not sure why its not a good answer. Check out this article which has a code sample to implement AJAX.

Jeremy
A: 

I'm doing something similar to this, and I ran into validation problems. It wouldn't let me communicate from my browser, unless my code was validated. The setup I went with was to install Tomcat server, and set up a Servlet.

http://java.sun.com/developer/technicalArticles/J2EE/AJAX/

This tutorial goes over the javascript, and servlet code for a basic validation script. This might help you get started.

Aaron