“cli和ser建立连接后,cli挂掉,ser知道吗?”
方法1:应用层自己实现的心跳包TCP socket心跳机制中,心跳包可以由服务器发送给客户端,也可以由客户端发送给服务器,不过比较起来,前者开销可能更大。因此一般是由客户端给服务器发送心跳包。比如这个示例:https://blog.csdn.net/lisonglisonglisong/article/details/51327695
方法2:TCP的KeepAlive保活机制
——“断电和超时是同一个现象。。只能按超时处理”