Source file src/net/sockoptip_windows.go

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

View as plain text