From 6515cf12e520e2a6a8aad6cb0f7ef6cdb4f7443f Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Sun, 16 Apr 2017 21:31:28 +0200 Subject: [PATCH] log err on tcp test server --- testing/servers/tcp/tcp.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/testing/servers/tcp/tcp.go b/testing/servers/tcp/tcp.go index cf675614..0c06ec64 100644 --- a/testing/servers/tcp/tcp.go +++ b/testing/servers/tcp/tcp.go @@ -2,6 +2,7 @@ package tcp import ( "fmt" + "io" "net" v2net "v2ray.com/core/common/net" @@ -54,13 +55,19 @@ func (server *Server) handleConnection(conn net.Conn) { conn.Write(server.SendFirst) } request := make([]byte, 4096) - for true { + for { nBytes, err := conn.Read(request) if err != nil { + if err != io.EOF { + fmt.Println("Failed to read request:", err) + } break } response := server.MsgProcessor(request[:nBytes]) - conn.Write(response) + if _, err := conn.Write(response); err != nil { + fmt.Println("Failed to write response:", err) + break + } } conn.Close() }