github.com/bir3/gocompiler@v0.9.2202/src/internal/poll/sockopt.go (about)

     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  
     5  //go:build unix || windows
     6  
     7  package poll
     8  
     9  import "syscall"
    10  
    11  // SetsockoptInt wraps the setsockopt network call with an int argument.
    12  func (fd *FD) SetsockoptInt(level, name, arg int) error {
    13  	if err := fd.incref(); err != nil {
    14  		return err
    15  	}
    16  	defer fd.decref()
    17  	return syscall.SetsockoptInt(fd.Sysfd, level, name, arg)
    18  }
    19  
    20  // SetsockoptInet4Addr wraps the setsockopt network call with an IPv4 address.
    21  func (fd *FD) SetsockoptInet4Addr(level, name int, arg [4]byte) error {
    22  	if err := fd.incref(); err != nil {
    23  		return err
    24  	}
    25  	defer fd.decref()
    26  	return syscall.SetsockoptInet4Addr(fd.Sysfd, level, name, arg)
    27  }
    28  
    29  // SetsockoptLinger wraps the setsockopt network call with a Linger argument.
    30  func (fd *FD) SetsockoptLinger(level, name int, l *syscall.Linger) error {
    31  	if err := fd.incref(); err != nil {
    32  		return err
    33  	}
    34  	defer fd.decref()
    35  	return syscall.SetsockoptLinger(fd.Sysfd, level, name, l)
    36  }
    37  
    38  // GetsockoptInt wraps the getsockopt network call with an int argument.
    39  func (fd *FD) GetsockoptInt(level, name int) (int, error) {
    40  	if err := fd.incref(); err != nil {
    41  		return -1, err
    42  	}
    43  	defer fd.decref()
    44  	return syscall.GetsockoptInt(fd.Sysfd, level, name)
    45  }