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