JavaScript 标准参考教程草稿三:Node.js13.15 os模块
上一篇:13.14 Cluster模块
下一篇:13.16 Net模块和DNS...
13.15 os模块
os模块用于与硬件设备通信。
Socket通信
下面例子列出当前系列的所有IP地址。
var os = require('os');
var interfaces = os.networkInterfaces();
for (item in interfaces) {
console.log('Network interface name: ' + item);
for (att in interfaces[item]) {
var address = interfaces[item][att];
console.log('Family: ' + address.family);
console.log('IP Address: ' + address.address);
console.log('Is Internal: ' + address.internal);
console.log('');
}
console.log('==================================');
}
上一篇:13.14 Cluster模块
下一篇:13.16 Net模块和DNS...