0
我想平的結果(isAlive
)添加到流以下,這樣以後我能管的HTTP響應,但我收到以下錯誤的NodeJS創建自定義流
events.js:85
throw er; // Unhandled 'error' event
我不明白這意味着什麼,並會感激我提供的任何幫助?
var Readable = require('stream').Readable;
var s = new Readable;
var ping = require('ping');
var hosts = ['192.168.1.1', 'google.com', 'yahoo.com'];
hosts.forEach(function(host){
ping.sys.probe(host, function(isAlive){
var msg = isAlive ? 'host ' + host + ' is alive' : 'host ' + host + ' is dead';
//console.log(msg);
s.push(msg)
});
});
//s.push(null) ;
//s.pipe(process.stdout);
您正在使用哪個版本的節點? – Chance
我使用的是v0.10.40 – irom