0

There is a server I need to talk to that publishes a protocol over TCP/IP for querying data from a database and listening on a socket to receive notifications when data is updated. The sever guys provide a Java API which uses this TCP protocol. This means I could easily write a Swing App to talk to this server.

I would like a browser based solution. As the protocol is known to me, could I do this in JavaScript? My app will have to display the data in a table. I have heard of Web Sockets but I'm not sure if it will allow this two way communication. Is it feasible? Is there a better way that is cross platform and will work in most browsers? Should I be considering a Java Swing based solution that runs inside a browser?

EDIT: What about changing the code in my C++ server to add an additional interface that my Javascript code can communicate directly with it?

ScrollerBlaster
  • 1,578
  • 2
  • 17
  • 21

1 Answers1

1

The WebSocket protocol differs from TCP/IP sockets. You will have to write something to link them together.

You can do this perfectly well in JavaScript: use Node.js. There's enough tutorials to be found on the subject. The best way to link it to your in-browser JS is through Socket.IO.

  • Create a Node.js server that connects to the api
  • Make the server talk to your web app
  • Use it :)

This will work cross-platform and cross-browser (Socket.IO can use/emulate websockets even on IE6(!!)). You'll have to run a server-app (the Node.js app) though.

My personal opinion is that if you want a web/browser based solution, you should use native technology, and not Java.

Hope this helps :)

Arne
  • 424
  • 2
  • 5
  • @ame I have added more to my question. The gist is could I change my C++ server to support a web sockets friendly API and get my JavaScript code to use that? – ScrollerBlaster Nov 16 '12 at 16:49