Search code examples
javascriptserverp2ppeer

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)?


Solution

    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).