Node.js os模块
2021-09-15 16:33 更新
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('==================================');
}
以上内容是否对您有帮助:
更多建议: