...
Run Format

Source file src/net/sockoptip_windows.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  	"os"
     9  	"runtime"
    10  	"syscall"
    11  	"unsafe"
    12  )
    13  
    14  func setIPv4MulticastInterface(fd *netFD, ifi *Interface) error {
    15  	ip, err := interfaceToIPv4Addr(ifi)
    16  	if err != nil {
    17  		return os.NewSyscallError("setsockopt", err)
    18  	}
    19  	var a [4]byte
    20  	copy(a[:], ip.To4())
    21  	err = fd.pfd.Setsockopt(syscall.IPPROTO_IP, syscall.IP_MULTICAST_IF, (*byte)(unsafe.Pointer(&a[0])), 4)
    22  	runtime.KeepAlive(fd)
    23  	return wrapSyscallError("setsockopt", err)
    24  }
    25  
    26  func setIPv4MulticastLoopback(fd *netFD, v bool) error {
    27  	err := fd.pfd.SetsockoptInt(syscall.IPPROTO_IP, syscall.IP_MULTICAST_LOOP, boolint(v))
    28  	runtime.KeepAlive(fd)
    29  	return wrapSyscallError("setsockopt", err)
    30  }
    31  

View as plain text