简体   繁体   中英

How to create a nodejs websocket client

I'm working on a project where I need to have multiple node clients connect to a node server via websockets. The clients will send files to the server and the server will immediately distribute that file to all connected clients.

The problem I'm running into is connecting as a client in node. The built in ws module seems to only support server use. I've also tried the npm websocket client which allows me to use node as a client but I seem to only be able to send binary data without any other information like the filename, etc. using the sendBytes method.

Thanks for any suggestions.

Checkout the delivery package of npm . It provides bi-directional file tranfer for node.js over socket.io.

https://www.npmjs.com/package/delivery

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM