commit 25ae442

delthas  ·  2022-04-08 14:48:10 +0000 UTC
parent dcaf0b6
Add a 15s keepalive to connections

My DSL line is awful atm, I'd like to know ASAP when I'm disconnected so
that I don't write paragraphs into the void.
1 files changed,  +5, -0
M app.go
M app.go
+5, -0
 1@@ -351,6 +351,11 @@ func (app *App) tryConnect() (conn net.Conn, err error) {
 2 		return
 3 	}
 4 
 5+	if tcpConn, ok := conn.(*net.TCPConn); ok {
 6+		tcpConn.SetKeepAlive(true)
 7+		tcpConn.SetKeepAlivePeriod(15 * time.Second)
 8+	}
 9+
10 	if app.cfg.TLS {
11 		host, _, _ := net.SplitHostPort(addr) // should succeed since net.Dial did.
12 		conn = tls.Client(conn, &tls.Config{