小编FWi*_*ing的帖子

将数据写入Node.js中的文本文件

目前,我有以下代码块:

net = require('net');
var clients = [];

net.createServer(function(s) {

  clients.push(s);

  s.on('data', function (data) {
    clients.forEach(function(c) {
      c.write(data);
    });
    process.stdout.write(data);//write data to command window
  });

  s.on('end', function() {
    process.stdout.write("lost connection");
  });

}).listen(9876);
Run Code Online (Sandbox Code Playgroud)

用于将我的Windows计算机设置为服务器并从我的Linux计算机接收数据.它当前正在将数据写入命令窗口.我想将数据写入文本文件到特定位置,我该怎么做?

file-io node.js

6
推荐指数
1
解决办法
7575
查看次数

标签 统计

file-io ×1

node.js ×1