...
Run Format

Source file src/net/sockoptip_linux.go

Documentation: net

     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  package net
     6  
     7  import (
     8  	"runtime"
     9  	"syscall"
    10  )
    11  
    12  func setIPv4MulticastInterface(fd *netFD, ifi *Interface) error {
    13  	var v int32
    14  	if ifi != nil {
    15  		v = int32(ifi.Index)
    16  	}
    17  	mreq := &syscall.IPMreqn{Ifindex: v}
    18  	err := fd.pfd.SetsockoptIPMreqn(syscall.IPPROTO_IP, syscall.IP_MULTICAST_IF, mreq)
    19  	runtime.KeepAlive(fd)
    20  	return wrapSyscallError("setsockopt", err)
    21  }
    22  
    23  func setIPv4MulticastLoopback(fd *netFD, v bool) error {
    24  	err := fd.pfd.SetsockoptInt(syscall.IPPROTO_IP, syscall.IP_MULTICAST_LOOP, boolint(v))
    25  	runtime.KeepAlive(fd)
    26  	return wrapSyscallError("setsockopt", err)
    27  }
    28  

View as plain text