summaryrefslogtreecommitdiffhomepage
path: root/net/ktimeout/ktimeout_linux.go
blob: 634c32119b569d6c143cfff59f5ebf69b9370935 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// Copyright (c) Tailscale Inc & contributors
// SPDX-License-Identifier: BSD-3-Clause

package ktimeout

import (
	"time"

	"golang.org/x/sys/unix"
)

// SetUserTimeout sets the TCP_USER_TIMEOUT option on the given file descriptor.
func SetUserTimeout(fd uintptr, timeout time.Duration) error {
	return unix.SetsockoptInt(int(fd), unix.SOL_TCP, unix.TCP_USER_TIMEOUT, int(timeout/time.Millisecond))
}