Node.js/TCP:修订间差异

来自康健生活
Kangkk​(留言 | 贡献)
Kangkk​(留言 | 贡献)
第16行: 第16行:
== 长连接 ==
== 长连接 ==
== 心跳包 ==
== 心跳包 ==
== 断开 ==
断开连接监听。
<syntaxhighlight lang="javascript">
this.ctx.req.on('error', () => {
  console.log('req error');
});
this.ctx.req.on('close', () => {
  console.log('req close');
});
this.ctx.res.on('error', () => {
  console.log('res error');
});
this.ctx.res.on('close', () => {
  console.log('res close');
});
this.ctx.socket.on('error', () => {
  console.log('socket error');
});
this.ctx.socket.on('close', () => {
  console.log('socket close');
});</syntaxhighlight>