开发者

How to inform the server when a client is interrupted?

开发者 https://www.devze.com 2022-12-15 00:50 出处:网络
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 - thi

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

精彩评论

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