Node.js/TCP:修订间差异
来自康健生活
| (未显示同一用户的2个中间版本) | |||
| 第14行: | 第14行: | ||
Insert comment here | Insert comment here | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== 长连接 == | |||
== 心跳包 == | |||
== 断开 == | |||
断开连接监听。 | |||
TODO, thinkjs, 等待详说。 | |||
<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> | |||