github.com/FISCO-BCOS/crypto@v0.0.0-20200202032121-bd8ab0b5d4f1/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 // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris 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 }