ktimeout_linux.go 397 B

123456789101112131415
  1. // Copyright (c) Tailscale Inc & AUTHORS
  2. // SPDX-License-Identifier: BSD-3-Clause
  3. package ktimeout
  4. import (
  5. "time"
  6. "golang.org/x/sys/unix"
  7. )
  8. // SetUserTimeout sets the TCP_USER_TIMEOUT option on the given file descriptor.
  9. func SetUserTimeout(fd uintptr, timeout time.Duration) error {
  10. return unix.SetsockoptInt(int(fd), unix.SOL_TCP, unix.TCP_USER_TIMEOUT, int(timeout/time.Millisecond))
  11. }