How can I communicate over TCP sockets from JavaSc

2019-01-08 12:56发布

I'm thinking about how limiting it is for AJAX apps to have to poll for updates, when what would be ideal is for javascript to be able to set up a real two way connection to the server. I'm wondering if there is some method of integrating javascript with a browser plugin that can make a tcp connection so that I could pass data into and out of the browser plugin.

4条回答
够拽才男人
2楼-- · 2019-01-08 13:05

jSocket and Stream are two options that utilize Flash's built-in XML sockets, though neither appears to be production-ready. I'd lean towards using a Flash-based solution rather than Java, as browser penetration is higher and generally offers a better user experience (load times & stability).

查看更多
甜甜的少女心
3楼-- · 2019-01-08 13:06

WebSockets is designed to solve this problem.

查看更多
爷的心禁止访问
4楼-- · 2019-01-08 13:17

You can use node.js framework's socket.io package which can can be installed via npm (A node package manager).

More detailed usage.

查看更多
The star\"
5楼-- · 2019-01-08 13:31

Here is an implementation with a similar approach:

It uses a Java Applet and bridges its API to JavaScript, interesting...

And here another one:

This one is a wrapper of the Actionscript 3 Socket API, bridged to JavaScript...

查看更多
登录 后发表回答