From 6730d80469296b2746a326494fa4214e67eefe07 Mon Sep 17 00:00:00 2001 From: john Date: Tue, 25 Sep 2018 09:43:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9Bgtcp/gudp=E8=B6=85=E6=97=B6?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E5=88=A4=E6=96=AD=E6=9C=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- g/net/gtcp/gtcp_func.go | 6 ++++-- g/net/gudp/gudp_func.go | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/g/net/gtcp/gtcp_func.go b/g/net/gtcp/gtcp_func.go index 1f007ed59..f496143b1 100644 --- a/g/net/gtcp/gtcp_func.go +++ b/g/net/gtcp/gtcp_func.go @@ -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 } \ No newline at end of file diff --git a/g/net/gudp/gudp_func.go b/g/net/gudp/gudp_func.go index 3c6b15412..c151516d2 100644 --- a/g/net/gudp/gudp_func.go +++ b/g/net/gudp/gudp_func.go @@ -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 } \ No newline at end of file