From 60a8de13e7a40a89a17d2882e1db1dd81b0194b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Sat, 10 Dec 2022 18:22:00 +0800 Subject: [PATCH] =?UTF-8?q?TCP=E5=8D=95=E6=AC=A1=E5=90=91=E5=AE=A2?= =?UTF-8?q?=E6=88=B7=E7=AB=AF=E5=86=99=E5=85=A5=E6=95=B0=E6=8D=AE=E6=97=B6?= =?UTF-8?q?=E8=B6=85=E8=BF=8730=E7=A7=92=E5=8D=B3=E8=AE=A4=E4=B8=BA?= =?UTF-8?q?=E8=B6=85=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/nodes/client_conn.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/nodes/client_conn.go b/internal/nodes/client_conn.go index e4e6fae..d7f10c2 100644 --- a/internal/nodes/client_conn.go +++ b/internal/nodes/client_conn.go @@ -114,6 +114,9 @@ func (this *ClientConn) Read(b []byte) (n int, err error) { } func (this *ClientConn) Write(b []byte) (n int, err error) { + // 设置超时时间 + _ = this.rawConn.SetWriteDeadline(time.Now().Add(30 * time.Second)) // TODO 时间可以设置 + n, err = this.rawConn.Write(b) if n > 0 { // 统计当前服务带宽