github.com/hxx258456/ccgo@v0.0.5-0.20230213014102-48b35f46f66f/internal/poll/sockoptip.go (about)

     1  // Copyright 2011 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 aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || windows
     6  // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris windows
     7  
     8  package poll
     9  
    10  import "syscall"
    11  
    12  // SetsockoptIPMreq wraps the setsockopt network call with an IPMreq argument.
    13  func (fd *FD) SetsockoptIPMreq(level, name int, mreq *syscall.IPMreq) error {
    14  	if err := fd.incref(); err != nil {
    15  		return err
    16  	}
    17  	defer fd.decref()
    18  	return syscall.SetsockoptIPMreq(fd.Sysfd, level, name, mreq)
    19  }
    20  
    21  // SetsockoptIPv6Mreq wraps the setsockopt network call with an IPv6Mreq argument.
    22  func (fd *FD) SetsockoptIPv6Mreq(level, name int, mreq *syscall.IPv6Mreq) error {
    23  	if err := fd.incref(); err != nil {
    24  		return err
    25  	}
    26  	defer fd.decref()
    27  	return syscall.SetsockoptIPv6Mreq(fd.Sysfd, level, name, mreq)
    28  }