...
  
  Source file src/net/tcpsockopt_windows.go
     1	
     2	
     3	
     4	
     5	package net
     6	
     7	import (
     8		"os"
     9		"runtime"
    10		"syscall"
    11		"time"
    12		"unsafe"
    13	)
    14	
    15	func setKeepAlivePeriod(fd *netFD, d time.Duration) error {
    16		
    17		
    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,
    24		}
    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)
    30	}
    31	
View as plain text