我tcp client在 nodejs 中編寫(xiě)了以下內(nèi)容。const net = require('net');const HOST = 'linux345';const PORT = 2345;let ErrCode = 1;const client = new net.Socket();client.connect(PORT, HOST, function() { ErrCode = 0;});client.on('data', function(data) { console.log('Client received: ' + data); if (data.toString().endsWith('exit')) { client.destroy(); }});client.on('close', function() {});client.on('error', function(err) { ErrCode = err.code; console.log(ErrCode);});console.log(ErrCode);請(qǐng)建議我如何使用 async/await 編寫(xiě)相同的邏輯
如何使用 async/await 在 NodeJS 中創(chuàng)建 TCP 客戶端?
繁星淼淼
2021-11-12 18:35:03