tcpsockopt_posix.go 524 B

123456789101112131415161718
  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.
  4. //go:build aix || darwin || dragonfly || freebsd || hurd || linux || netbsd || openbsd || solaris || windows
  5. package net
  6. import (
  7. "runtime"
  8. "syscall"
  9. )
  10. func setNoDelay(fd *netFD, noDelay bool) error {
  11. err := fd.pfd.SetsockoptInt(syscall.IPPROTO_TCP, syscall.TCP_NODELAY, boolint(noDelay))
  12. runtime.KeepAlive(fd)
  13. return wrapSyscallError("setsockopt", err)
  14. }