我写了一段发送数据包到套接字并从中读取的代码。但是当我运行它时,虽然我从套接字中获取了数据,但代码会抛出一个错误,说是read 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);
})