-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathsockopt_darwin.go
51 lines (44 loc) · 1.26 KB
/
sockopt_darwin.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright 2014 Mikio Hara. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package tcp
import (
"os"
"syscall"
"time"
)
func (c *Conn) setKeepAliveIdleInterval(d time.Duration) error {
fd, err := c.sysfd()
if err != nil {
return err
}
d += (time.Second - time.Nanosecond)
secs := int(d.Seconds())
return os.NewSyscallError("setsockopt", syscall.SetsockoptInt(fd, ianaProtocolTCP, sysTCP_KEEPALIVE, secs))
}
func (c *Conn) setKeepAliveProbeInterval(d time.Duration) error {
fd, err := c.sysfd()
if err != nil {
return err
}
d += (time.Second - time.Nanosecond)
secs := int(d.Seconds())
return os.NewSyscallError("setsockopt", syscall.SetsockoptInt(fd, ianaProtocolTCP, sysTCP_KEEPINTVL, secs))
}
func (c *Conn) setKeepAliveProbes(n int) error {
fd, err := c.sysfd()
if err != nil {
return err
}
return os.NewSyscallError("setsockopt", syscall.SetsockoptInt(fd, ianaProtocolTCP, sysTCP_KEEPCNT, n))
}
func (c *Conn) setCork(on bool) error {
fd, err := c.sysfd()
if err != nil {
return err
}
return os.NewSyscallError("setsockopt", syscall.SetsockoptInt(fd, ianaProtocolTCP, sysTCP_NOPUSH, boolint(on)))
}
func (c *Conn) info() (*Info, error) {
return nil, errOpNoSupport
}