增加重连

This commit is contained in:
qiyunfanbo126.com 2025-01-22 15:15:10 +08:00
parent 322a051f32
commit 92ebac31b9
1 changed files with 5 additions and 5 deletions

View File

@ -112,11 +112,11 @@ func (t *TcpHelper) Close(conn net.Conn) {
}
func (t *TcpHelper) watch(conn net.Conn) {
go func() {
//defer func() {
// if err := recover(); err != nil {
// fmt.Println("连接断开", err)
// }
//}()
defer func() {
if err := recover(); err != nil {
fmt.Println("连接断开", err)
}
}()
for {
conn.SetWriteDeadline(time.Now().Add(expire))
_, err := conn.Write([]byte("1\n"))