mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 15:04:03 +03:00
Fix Keep-Alive Issue for OpenBSD/ArchLinux
This commit is contained in:
@@ -3,11 +3,8 @@ package utils
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const tcpKeepAlivePingPeriod = 2 * time.Second
|
|
||||||
|
|
||||||
func InitTCP(conn net.Conn, readBufferSize int, writeBufferSize int) error {
|
func InitTCP(conn net.Conn, readBufferSize int, writeBufferSize int) error {
|
||||||
tcpConn := conn.(*net.TCPConn)
|
tcpConn := conn.(*net.TCPConn)
|
||||||
|
|
||||||
@@ -27,9 +24,5 @@ func InitTCP(conn net.Conn, readBufferSize int, writeBufferSize int) error {
|
|||||||
return fmt.Errorf("cannot enable keep-alive: %w", err)
|
return fmt.Errorf("cannot enable keep-alive: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := tcpConn.SetKeepAlivePeriod(tcpKeepAlivePingPeriod); err != nil {
|
|
||||||
return fmt.Errorf("cannot set keep-alive period: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user