log err on tcp test server

pull/432/merge
Darien Raymond 8 years ago
parent 57a353e92f
commit 6515cf12e5
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169

@ -2,6 +2,7 @@ package tcp
import ( import (
"fmt" "fmt"
"io"
"net" "net"
v2net "v2ray.com/core/common/net" v2net "v2ray.com/core/common/net"
@ -54,13 +55,19 @@ func (server *Server) handleConnection(conn net.Conn) {
conn.Write(server.SendFirst) conn.Write(server.SendFirst)
} }
request := make([]byte, 4096) request := make([]byte, 4096)
for true { for {
nBytes, err := conn.Read(request) nBytes, err := conn.Read(request)
if err != nil { if err != nil {
if err != io.EOF {
fmt.Println("Failed to read request:", err)
}
break break
} }
response := server.MsgProcessor(request[:nBytes]) 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() conn.Close()
} }

Loading…
Cancel
Save