Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1466)

Issue 4066044: code review 4066044: net: Add IPv4 Multicast support to UDPConn (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
14 years, 3 months ago by dave
Modified:
14 years, 2 months ago
Reviewers:
CC:
adg, rsc, golang-dev
Visibility:
Public.

Description

net: Add IPv4 Multicast support to UDPConn notes: Darwin is very particular about joining a multicast group if the listneing socket is not created in "udp4" mode, the other supported OS's are more flexible. A simple example sets up a socket to listen on the mdns/bonjour group 224.0.0.251:5353 // ensure the sock is udp4, and the IP is a 4 byte IPv4 socket, err := net.ListenUDP("udp4", &net.UDPAddr { IP: net.IPv4zero, // currently darwin will not allow you to bind to // a port if it is already bound to another process Port: 5353, }) if err != nil { log.Exitf("listen %s", err) } defer socket.Close() err = socket.JoinGroup(net.IPv4(224, 0, 0, 251)) if err != nil { log.Exitf("join group %s", err) }

Patch Set 1 #

Patch Set 2 : code review 4066044: net: Add IPv4 Multicast support to UDPConn #

Patch Set 3 : code review 4066044: net: Add IPv4 Multicast support to UDPConn #

Total comments: 10

Patch Set 4 : diff -r 85f202d81c64 https://go.googlecode.com/hg/ #

Total comments: 18

Patch Set 5 : diff -r 4decd02fda70 https://go.googlecode.com/hg/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+97 lines, -0 lines) Patch
A src/pkg/net/multicast_test.go View 1 2 3 4 1 chunk +56 lines, -0 lines 0 comments Download
M src/pkg/net/udpsock.go View 1 2 3 4 1 chunk +41 lines, -0 lines 0 comments Download

Messages

Total messages: 18
dave_cheney.net
Hello adg, rsc (cc: golang-dev@googlegroups.com), I'd like you to review this change.
14 years, 3 months ago (2011-01-27 12:21:16 UTC) #1
rsc
> Support for multicast differs between darwin, linux and freebsd. If that's the case then ...
14 years, 3 months ago (2011-01-27 13:16:41 UTC) #2
dave_cheney.net
Hello adg, rsc (cc: golang-dev@googlegroups.com), Please take another look.
14 years, 3 months ago (2011-01-27 21:40:20 UTC) #3
dave_cheney.net
Hi Russ, That might have been the wrong turn of phrase. What I mean to ...
14 years, 3 months ago (2011-01-27 21:46:13 UTC) #4
rsc
http://codereview.appspot.com/4066044/diff/5001/src/pkg/net/udpsock.go File src/pkg/net/udpsock.go (right): http://codereview.appspot.com/4066044/diff/5001/src/pkg/net/udpsock.go#newcode285 src/pkg/net/udpsock.go:285: // JoinGroup establishes a membership of an IPv4 Multicast ...
14 years, 2 months ago (2011-02-01 16:41:53 UTC) #5
dave_cheney.net
> http://codereview.appspot.com/4066044/diff/5001/src/pkg/net/udpsock.go#newcode285 > src/pkg/net/udpsock.go:285: // JoinGroup establishes a membership of an IPv4 > Multicast group ...
14 years, 2 months ago (2011-02-01 22:16:30 UTC) #6
rsc
>> src/pkg/net/udpsock.go:297: return os.NewSyscallError("setsockopt", >> syscall.SetsockoptString(c.fd.sysfd, syscall.IPPROTO_IP, >> syscall.IP_ADD_MEMBERSHIP, makeMReqString(ip))) >> If there's an error ...
14 years, 2 months ago (2011-02-01 22:18:15 UTC) #7
dave_cheney.net
> Yes, I have code for this and was intending to submit it as a ...
14 years, 2 months ago (2011-02-01 22:48:53 UTC) #8
rsc
> On reflection I think i'll submit the underlying changes to the syscall > pkg ...
14 years, 2 months ago (2011-02-01 23:15:38 UTC) #9
dave_cheney.net
Will do, the major difference is godef has changed template for padded structs which makes ...
14 years, 2 months ago (2011-02-01 23:49:11 UTC) #10
dave_cheney.net
Hello adg, rsc (cc: golang-dev@googlegroups.com), I'd like you to review this change to https://go.googlecode.com/hg/
14 years, 2 months ago (2011-02-03 22:29:17 UTC) #11
dave_cheney.net
PTAL http://codereview.appspot.com/4066044/diff/5001/src/pkg/net/udpsock.go File src/pkg/net/udpsock.go (right): http://codereview.appspot.com/4066044/diff/5001/src/pkg/net/udpsock.go#newcode285 src/pkg/net/udpsock.go:285: // JoinGroup establishes a membership of an IPv4 ...
14 years, 2 months ago (2011-02-03 22:30:18 UTC) #12
dave_cheney.net
PTAL
14 years, 2 months ago (2011-02-10 23:32:56 UTC) #13
rsc
looks good http://codereview.appspot.com/4066044/diff/18002/src/pkg/net/multicast_test.go File src/pkg/net/multicast_test.go (right): http://codereview.appspot.com/4066044/diff/18002/src/pkg/net/multicast_test.go#newcode17 src/pkg/net/multicast_test.go:17: socket, err := ListenUDP("udp4", addr) s/socket/conn/ not ...
14 years, 2 months ago (2011-02-11 19:38:40 UTC) #14
dave_cheney.net
Thanks Russ, please take another look http://codereview.appspot.com/4066044/diff/18002/src/pkg/net/multicast_test.go File src/pkg/net/multicast_test.go (right): http://codereview.appspot.com/4066044/diff/18002/src/pkg/net/multicast_test.go#newcode17 src/pkg/net/multicast_test.go:17: socket, err := ...
14 years, 2 months ago (2011-02-12 01:28:40 UTC) #15
dave_cheney.net
Hello adg, rsc (cc: golang-dev@googlegroups.com), Please take another look.
14 years, 2 months ago (2011-02-12 01:29:22 UTC) #16
rsc
LGTM
14 years, 2 months ago (2011-02-16 20:06:41 UTC) #17
rsc
14 years, 2 months ago (2011-02-16 20:07:15 UTC) #18
*** Submitted as 4892f94182a5 ***

net: add IPv4 multicast to UDPConn

notes:
Darwin is very particular about joining a multicast group if the
listneing socket is not created in "udp4" mode, the other supported
OS's are more flexible.

A simple example sets up a socket to listen on the mdns/bonjour
group 224.0.0.251:5353

// ensure the sock is udp4, and the IP is a 4 byte IPv4
socket, err := net.ListenUDP("udp4", &net.UDPAddr {
        IP: net.IPv4zero,
        // currently darwin will not allow you to bind to
        // a port if it is already bound to another process
        Port: 5353,
})
if err != nil {
        log.Exitf("listen %s", err)
}
defer socket.Close()
err = socket.JoinGroup(net.IPv4(224, 0, 0, 251))
if err != nil {
        log.Exitf("join group %s", err)
}

R=adg, rsc
CC=golang-dev
http://codereview.appspot.com/4066044

Committer: Russ Cox <rsc@golang.org>
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b