Nodejs套接字连接错误

我已经写了这个代码发送数据包到套接字并从中读取。 但是当我运行它时,我从套接字获取数据,但代码抛出错误说阅读ECONNRESET。 我做错了什么?

var client = net.connect({port:remotePort, host:remoteIpAddress},function(){ client.write(packet); }); client.on('data',function(chunkData){ console.log(chunkData); client.end(); }); client.on('end',function(){ console.log("Reading end"); }); client.on('error', function(err){ console.log("Error: "+err.message); }) 

你的代码应该没问题。 ECONNRESET意味着套接字的另一端意外中止了连接。 这不是导致此错误的客户端代码。

另见上一个关于同一主题的问题