wsarecv: An existing connection was forcibly closed by the remote host.

read tcp 127.0.0.1:8848->127.0.0.1:58625: wsarecv: An existing connection was forcibly closed by the remote host.【远程主机强制关闭了现有连接。】tcp协议,一主机对多客户端时,服务器经常会报这个异常而关闭,我也曾翻译了他的意思,但只是明白了文字,为什么?我不知道。直到我看到了客户端代码在处理异常的最后os.Exit(1),我明白了,首先这个业务逻辑就是不合理的,客户端的异常怎么可以直接导致服务端的关闭,包括以前的调试中的服务器异常退出也就自然明白了,因为这个,因为客服端的异常处理顺带的推出了系统。这里的业务逻辑应该改成,客户端发现异常,只有上传异常日志的权限。

wsarecv: An existing connection was forcibly closed by the remote host.【服务没有被正常关闭】原因:

1、服务端本身检查os.Exit出现的位置,业务。

2、客户端os.Exit出现的原因,应该说客户端不应该出现这个。

 

猜你喜欢

转载自blog.csdn.net/ckx178/article/details/88526186