tags:

views:

808

answers:

2

hi,

I am trying to write an application that uses java.net.Socket. I have also written an app in Java using GWT to display the contents from an ArrayList.

However, I now need to populate that ArrayList via a socket connection. Apparently Google Web Toolkit does not support socket connections. Can anyone please give me a workaround for this? Any examples or links to examples will be much appreciated.

Regards

+2  A: 

You have basically two options:

  • Use HTTP Connections from your client code (GWT RPC, some other framework, or handrolled). Then you can make your Socket connections from the server
  • Put together a Java applet (or possibly a Flash client) on the client to do this, and then write your own GWT components to communicate with the applet

Browsers do not support direct socket connections from Javascript, so it isn't possible to support java.net.socket directly in GWT client code.

jsight
+2  A: 

GWT is designed to be hooked up to a back end server, and this is where you would make any socket connections that you require. GWT is front-end technology, and because it is compiled to javascript cannot do things like make socket connections. You can use whatever technology you want on the back end, and hook it into your java: - Java back end (talk to it via RPC calls) - Ruby/PHP back end (talk to it via JSON or XML) - etc

rustyshelf