Source file
src/net/tcpsock_unix.go
1
2
3
4
5
6
7 package net
8
9 import "syscall"
10
11
12 func (c *TCPConn) SetKeepAliveConfig(config KeepAliveConfig) error {
13 if !c.ok() {
14 return syscall.EINVAL
15 }
16
17 if err := setKeepAlive(c.fd, config.Enable); err != nil {
18 return &OpError{Op: "set", Net: c.fd.net, Source: c.fd.laddr, Addr: c.fd.raddr, Err: err}
19 }
20 if err := setKeepAliveIdle(c.fd, config.Idle); err != nil {
21 return &OpError{Op: "set", Net: c.fd.net, Source: c.fd.laddr, Addr: c.fd.raddr, Err: err}
22 }
23 if err := setKeepAliveInterval(c.fd, config.Interval); err != nil {
24 return &OpError{Op: "set", Net: c.fd.net, Source: c.fd.laddr, Addr: c.fd.raddr, Err: err}
25 }
26 if err := setKeepAliveCount(c.fd, config.Count); err != nil {
27 return &OpError{Op: "set", Net: c.fd.net, Source: c.fd.laddr, Addr: c.fd.raddr, Err: err}
28 }
29
30 return nil
31 }
32
View as plain text