简体   繁体   English

Node.js-在Unix套接字上侦听并将数据传输到连接的Websocket(socket.io)客户端

[英]Node.js - listen on unix socket and transfer data to connected websocket (socket.io) clients

I have a small webcrawler written in C that collects some data from different websites and creates json-objects that are sent through a unix socket as a utf-8 encoded string. 我有一个用C编写的小型网络爬虫,该爬虫从不同的网站收集一些数据,并创建通过unix套接字作为utf-8编码字符串发送的json对象。

Node.js is listening on that socket-file and receives all the json-strings. Node.js正在侦听该套接字文件并接收所有json字符串。

Now the question is - how can I accomplish it, that this data is sent to all connected socket.io clients? 现在的问题是-如何将这些数据发送到所有连接的socket.io客户端?

Thanks in advance and sorry for my bad english. 在此先感谢您,我的英语不好。

On the server end: 在服务器端:

var io = require('socket.io');

Then, when you have some data to send to all connected websockets: 然后,当您有一些数据要发送到所有连接的网络套接字时:

io.emit('someMsg', data);

See the documentation here . 请参阅此处的文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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