How to use the net module from Node.js with browserify?

前端 未结 1 842
半阙折子戏
半阙折子戏 2020-12-18 07:32

I want to use the net module from Node.js on the client side (in the browser):

var net = require(\'net\');

So I looked up how

相关标签:
1条回答
  • 2020-12-18 08:14

    This is because net gives you access to raw TCP sockets - which browsers simply cannot do from the JavaScript end. It is impossible for net to ever be ported to the client side until such an API is written (allowing arbitrary tcp traffic).

    Your best bet if you want to send tcp data from the client to the server is using web sockets using the socket.io module or the ws one.

    Your best bet if you want clients to communicate directly is to look into WebRTC

    0 讨论(0)
提交回复
热议问题