|
|
@@ -3,11 +3,8 @@ package utils
|
|
3
|
3
|
import (
|
|
4
|
4
|
"fmt"
|
|
5
|
5
|
"net"
|
|
6
|
|
- "time"
|
|
7
|
6
|
)
|
|
8
|
7
|
|
|
9
|
|
-const tcpKeepAlivePingPeriod = 2 * time.Second
|
|
10
|
|
-
|
|
11
|
8
|
func InitTCP(conn net.Conn, readBufferSize int, writeBufferSize int) error {
|
|
12
|
9
|
tcpConn := conn.(*net.TCPConn)
|
|
13
|
10
|
|
|
|
@@ -27,9 +24,5 @@ func InitTCP(conn net.Conn, readBufferSize int, writeBufferSize int) error {
|
|
27
|
24
|
return fmt.Errorf("cannot enable keep-alive: %w", err)
|
|
28
|
25
|
}
|
|
29
|
26
|
|
|
30
|
|
- if err := tcpConn.SetKeepAlivePeriod(tcpKeepAlivePingPeriod); err != nil {
|
|
31
|
|
- return fmt.Errorf("cannot set keep-alive period: %w", err)
|
|
32
|
|
- }
|
|
33
|
|
-
|
|
34
|
27
|
return nil
|
|
35
|
28
|
}
|