Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to open a port in Javascript for communication on the network?

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 communications using JavaScript? So devices can talk to each other on a network, peer2peer (acting like a server)?

like image 696
Kevin Van Ryckegem Avatar asked Mar 18 '17 14:03

Kevin Van Ryckegem


1 Answers

  1. You can't use real TCP or UDP sockets in the browser.
  2. You may use WebSockets to communicate 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).
like image 90
ilyaigpetrov Avatar answered Nov 15 '22 05:11

ilyaigpetrov