libgo: update to Go 1.11
[official-gcc.git] / libgo / go / net / tcpsockopt_windows.go
blob73dead11d00be6597a8b4a792fb3e0fde3aaad7d
1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 package net
7 import (
8 "os"
9 "runtime"
10 "syscall"
11 "time"
12 "unsafe"
15 func setKeepAlivePeriod(fd *netFD, d time.Duration) error {
16 // The kernel expects milliseconds so round to next highest
17 // millisecond.
18 d += (time.Millisecond - time.Nanosecond)
19 msecs := uint32(d / time.Millisecond)
20 ka := syscall.TCPKeepalive{
21 OnOff: 1,
22 Time: msecs,
23 Interval: msecs,
25 ret := uint32(0)
26 size := uint32(unsafe.Sizeof(ka))
27 err := fd.pfd.WSAIoctl(syscall.SIO_KEEPALIVE_VALS, (*byte)(unsafe.Pointer(&ka)), size, nil, 0, &ret, nil, 0)
28 runtime.KeepAlive(fd)
29 return os.NewSyscallError("wsaioctl", err)