github.com/binkynet/BinkyNet@v1.12.1-0.20240421190447-da4e34c20be0/proto_vendor/golang.org/x/net/internal/socket/sys_unix.go (about)

     1  // Copyright 2017 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  // +build dragonfly freebsd linux,!s390x,!386 netbsd openbsd
     6  
     7  package socket
     8  
     9  import (
    10  	"syscall"
    11  	"unsafe"
    12  )
    13  
    14  func getsockopt(s uintptr, level, name int, b []byte) (int, error) {
    15  	l := uint32(len(b))
    16  	_, _, errno := syscall.Syscall6(syscall.SYS_GETSOCKOPT, s, uintptr(level), uintptr(name), uintptr(unsafe.Pointer(&b[0])), uintptr(unsafe.Pointer(&l)), 0)
    17  	return int(l), errnoErr(errno)
    18  }
    19  
    20  func setsockopt(s uintptr, level, name int, b []byte) error {
    21  	_, _, errno := syscall.Syscall6(syscall.SYS_SETSOCKOPT, s, uintptr(level), uintptr(name), uintptr(unsafe.Pointer(&b[0])), uintptr(len(b)), 0)
    22  	return errnoErr(errno)
    23  }
    24  
    25  func recvmsg(s uintptr, h *msghdr, flags int) (int, error) {
    26  	n, _, errno := syscall.Syscall(syscall.SYS_RECVMSG, s, uintptr(unsafe.Pointer(h)), uintptr(flags))
    27  	return int(n), errnoErr(errno)
    28  }
    29  
    30  func sendmsg(s uintptr, h *msghdr, flags int) (int, error) {
    31  	n, _, errno := syscall.Syscall(syscall.SYS_SENDMSG, s, uintptr(unsafe.Pointer(h)), uintptr(flags))
    32  	return int(n), errnoErr(errno)
    33  }