开发者

How to inform the server when a client is interrupted?

How to 开发者_运维知识库inform the server if a client is interrupted, and then close the socket?


If the other end of a socket is closed, your end will be marked as readable and return 0 from read - this is the "end of file" indication.

If you try to write to such a socket, you will recieve the SIGPIPE signal, and the write will return error with errno set to EPIPE ("Broken Pipe"). You must be prepared to handle this event, because the other end can close the socket at any time.


You need TCP_KEEPALIVE

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜