mirror of
https://gitee.com/johng/gf
synced 2026-06-07 10:22:11 +08:00
改进gtcp/gudp超时错误判断机制
This commit is contained in:
@ -9,7 +9,6 @@ package gtcp
|
||||
import (
|
||||
"net"
|
||||
"time"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -85,5 +84,8 @@ func isTimeout(err error) bool {
|
||||
if err == nil {
|
||||
return false
|
||||
}
|
||||
return strings.Contains(err.Error(), "timeout")
|
||||
if netErr, ok := err.(net.Error); ok && netErr.Timeout() {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
@ -8,7 +8,6 @@ package gudp
|
||||
|
||||
import (
|
||||
"net"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// 创建标准库UDP链接操作对象
|
||||
@ -57,5 +56,8 @@ func isTimeout(err error) bool {
|
||||
if err == nil {
|
||||
return false
|
||||
}
|
||||
return strings.Contains(err.Error(), "timeout")
|
||||
if netErr, ok := err.(net.Error); ok && netErr.Timeout() {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
Reference in New Issue
Block a user