最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

server - Is it possible to open a port in Javascript for communication on the network? - Stack Overflow

programmeradmin0浏览0评论

I saw that Socket.IO and Websockets usually require NodeJS or similar but don't run on clients.

Is there any possible way to open a port for accepting munications using JavaScript? So devices can talk to each other on a network, peer2peer (acting like a server)?

I saw that Socket.IO and Websockets usually require NodeJS or similar but don't run on clients.

Is there any possible way to open a port for accepting munications using JavaScript? So devices can talk to each other on a network, peer2peer (acting like a server)?

Share Improve this question asked Mar 18, 2017 at 14:54 Kevin Van RyckegemKevin Van Ryckegem 1,9454 gold badges30 silver badges55 bronze badges 1
  • browser extensions may be able to. javascript running in webpages is not – the8472 Commented Mar 18, 2017 at 15:15
Add a ment  | 

1 Answer 1

Reset to default 6
  1. You can't use real TCP or UDP sockets in the browser.
  2. You may use WebSockets to municate to a server which translates WebSocket connection to real socket connection. Server may be written in NodeJS or other language/platform.
  3. You can't listen for connections with WebSockets.
  4. You also may use WebRTC, which is also different from sockets, but better suited for peer-to-peer networks (I don't know very much about it).
发布评论

评论列表(0)

  1. 暂无评论