我正在编写一个可以侦听的应用程序tcp connection(请参阅此示例)。当tcp connection 断开连接时,我收到错误read tcp ip_server.:port1->ip_client:port2: wsarecv: An existing connection was forcibly closed by the remote host. 我预期错误EOF和超时(for conn.SetReadDeadline())并尝试使用以下代码捕获错误:if err != nil { log.Println("getting error from listener") // I thought, listener can continue work another cases if neterr, ok := err.(net.Error); ok && neterr.Timeout() || err == io.EOF { log.Println("Closing connection...") break // connection will be closed }}有人知道这个错误吗?您知道如何捕获此错误以及何时会发生此错误吗?提前致谢 !
- 1 回答
- 0 关注
- 610 浏览
添加回答
举报
0/150
提交
取消