* gcc-interface/decl.c (warn_on_field_placement): Issue the warning
[official-gcc.git] / libgo / go / net / tcpsockopt_windows.go
blob45a4dca5257d3e0a7b314fc31c5f53b8593bdae8
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 "syscall"
10 "time"
11 "unsafe"
14 func setKeepAlivePeriod(fd *netFD, d time.Duration) error {
15 if err := fd.incref(); err != nil {
16 return err
18 defer fd.decref()
19 // The kernel expects milliseconds so round to next highest
20 // millisecond.
21 d += (time.Millisecond - time.Nanosecond)
22 msecs := uint32(d / time.Millisecond)
23 ka := syscall.TCPKeepalive{
24 OnOff: 1,
25 Time: msecs,
26 Interval: msecs,
28 ret := uint32(0)
29 size := uint32(unsafe.Sizeof(ka))
30 err := syscall.WSAIoctl(fd.sysfd, syscall.SIO_KEEPALIVE_VALS, (*byte)(unsafe.Pointer(&ka)), size, nil, 0, &ret, nil, 0)
31 return os.NewSyscallError("wsaioctl", err)