Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/net: Implement PacketConn.JoinSourceSpecificGroup() and PacketConn.LeaveSourceSpecificGroup for Windows #40317

Misty418 opened this issue Jul 20, 2020 · 4 comments
NeedsInvestigation OS-Windows


Copy link

@Misty418 Misty418 commented Jul 20, 2020

What version of Go are you using (go version)?

go1.12.6 windows/amd64

Does this issue reproduce with the latest release?


What operating system and processor architecture are you using (go env)?

go env Output
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\Administrator\AppData\Local\go-build
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\Administrator\go
set GOROOT=c:\go
set GOTOOLDIR=c:\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\ADMINI~1\AppData\Local\Temp\go-build729998322=/tmp/go-build -gno-record-gcc-switches

What did you do?

Following this documentation we wanted to join a multicast group and receive packets from a specified source on Windows :

func (m *MCastSource) joinMulticastSourceGroup() error {
	var err error

	m.iface, err = net.InterfaceByName(m.ifaceName)
	if err != nil {
		return err

	// Listens on any interfaces
	m.netPacketConn, err = net.ListenPacket("udp4", "")
	if err != nil {
		return err
	m.ipv4PacketConn = ipv4.NewPacketConn(m.netPacketConn)

	groupIP := net.ParseIP(m.groupIp)
	sourceIP := net.ParseIP(m.sourceIp)
	m.ssmgroup = &net.UDPAddr{IP: net.IPv4(groupIP[12], groupIP[13], groupIP[14], groupIP[15])}
	m.ssmsource = &net.UDPAddr{IP: net.IPv4(sourceIP[12], sourceIP[13], sourceIP[14], sourceIP[15])}

	// Join source-specific multicast group
	if err := m.ipv4PacketConn.JoinSourceSpecificGroup(m.iface, m.ssmgroup, m.ssmsource); err != nil {
		return err

	return nil

What did you expect to see?

We expected to join a multicast group with a specified source.

What did you see instead?

An error message explaining that PacketConn.JoinSourceSpecificGroup() from /net/ipv4 is not implemented on Windows.

What's next?

A pull request will quickly follow this issue. This PR aims to add the support of JoinSourceSpecificGroup() and LeaveSourceSpecificGroup() to Windows OSes.
We plan on doing so by adding the IP_ADD_SOURCE_MEMBERSHIP and the IP_DROP_SOURCE_MEMBERSHIP options to the list of sockopts supported on Windows.

We do know that there's a more recent API ( that we could use to implement these two methods on Windows but we chose to use the IPProto socket options for the following reasons:

  • these socket options are part of the same group of options that is currently used by the net/ipv4 package to implement the JoinGroup() and LeaveGroup() methods on Windows (IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP). We find it more consistent to use the same API for both joining/leaving groups and source specific groups.
  • these socket options are available on a wider range of OSes (it was first added on Windows XP)
@Misty418 Misty418 changed the title net/ipv4 : Implement PacketConn.JoinSourceSpecificGroup() and PacketConn.LeaveSourceSpecificGroup for Windows x/net: Implement PacketConn.JoinSourceSpecificGroup() and PacketConn.LeaveSourceSpecificGroup for Windows Jul 21, 2020
@gopherbot gopherbot added this to the Unreleased milestone Jul 21, 2020
@toothrot toothrot added NeedsInvestigation OS-Windows labels Jul 21, 2020
Copy link

@toothrot toothrot commented Jul 21, 2020

/cc @bradfitz @ianlancetaylor

Copy link

@networkimprov networkimprov commented Jul 22, 2020

cc @alexbrainman

Copy link

@julienmathevet julienmathevet commented Nov 4, 2020

Any news about this bug and PR golang/net#79 ?

Copy link

@networkimprov networkimprov commented Nov 4, 2020

cc @mattn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
NeedsInvestigation OS-Windows
None yet

No branches or pull requests

5 participants