Skip to content

Commit 4de9d49

Browse files
committed
Bugfix Handling if the TCP connection was closed.
1 parent 97ae719 commit 4de9d49

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

client/util/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func (c *client) Run() {
2828
if len(connectionPool) < 10 {
2929
srvConn, err := c.DialSrv()
3030
if err != nil {
31-
log.Println(err)
31+
log.Printf("Connect to the server %s:%d failed: %s. \n", c.srvAddr.IP.String(), c.srvAddr.Port, err)
3232
continue
3333
}
3434
log.Printf("Connect to the server %s:%d successful.\n", c.srvAddr.IP.String(), c.srvAddr.Port)

service/service.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package service
22

33
import (
4-
"io"
54
"net"
65
)
76

@@ -35,11 +34,7 @@ func (s *Service) TransferToTCP(cliConn net.Conn, dstConn *net.TCPConn) error {
3534
if nRead > 0 {
3635
errWrite := s.TCPWrite(dstConn, buf[0:nRead])
3736
if err != nil {
38-
if errWrite == io.EOF {
39-
return nil
40-
} else {
41-
return errWrite
42-
}
37+
return errWrite
4338
}
4439
}
4540
}

0 commit comments

Comments
 (0)