Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
6d725e97
Commit
6d725e97
authored
Jan 14, 2013
by
Mikio Hara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
net: simplify ListenMulticastUDP
R=rsc, iant, dave CC=golang-dev
https://golang.org/cl/6999053
parent
c241f696
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
37 deletions
+12
-37
udpsock_posix.go
src/pkg/net/udpsock_posix.go
+12
-37
No files found.
src/pkg/net/udpsock_posix.go
View file @
6d725e97
...
...
@@ -211,25 +211,22 @@ func ListenMulticastUDP(net string, ifi *Interface, gaddr *UDPAddr) (*UDPConn, e
return
nil
,
UnknownNetworkError
(
net
)
}
if
gaddr
==
nil
||
gaddr
.
IP
==
nil
{
return
nil
,
&
OpError
{
"listen
multicast
"
,
net
,
nil
,
errMissingAddress
}
return
nil
,
&
OpError
{
"listen"
,
net
,
nil
,
errMissingAddress
}
}
fd
,
err
:=
internetSocket
(
net
,
gaddr
.
toAddr
(),
nil
,
noDeadline
,
syscall
.
SOCK_DGRAM
,
0
,
"listen"
,
sockaddrToUDP
)
if
err
!=
nil
{
return
nil
,
err
}
c
:=
newUDPConn
(
fd
)
ip4
:=
gaddr
.
IP
.
To4
()
if
ip4
!=
nil
{
err
:=
listenIPv4MulticastUDP
(
c
,
ifi
,
ip4
)
if
err
!=
nil
{
if
ip4
:=
gaddr
.
IP
.
To4
();
ip4
!=
nil
{
if
err
:=
listenIPv4MulticastUDP
(
c
,
ifi
,
ip4
);
err
!=
nil
{
c
.
Close
()
return
nil
,
err
return
nil
,
&
OpError
{
"listen"
,
net
,
&
IPAddr
{
IP
:
ip4
},
err
}
}
}
else
{
err
:=
listenIPv6MulticastUDP
(
c
,
ifi
,
gaddr
.
IP
)
if
err
!=
nil
{
if
err
:=
listenIPv6MulticastUDP
(
c
,
ifi
,
gaddr
.
IP
);
err
!=
nil
{
c
.
Close
()
return
nil
,
err
return
nil
,
&
OpError
{
"listen"
,
net
,
&
IPAddr
{
IP
:
gaddr
.
IP
},
err
}
}
}
return
c
,
nil
...
...
@@ -237,17 +234,14 @@ func ListenMulticastUDP(net string, ifi *Interface, gaddr *UDPAddr) (*UDPConn, e
func
listenIPv4MulticastUDP
(
c
*
UDPConn
,
ifi
*
Interface
,
ip
IP
)
error
{
if
ifi
!=
nil
{
err
:=
setIPv4MulticastInterface
(
c
.
fd
,
ifi
)
if
err
!=
nil
{
if
err
:=
setIPv4MulticastInterface
(
c
.
fd
,
ifi
);
err
!=
nil
{
return
err
}
}
err
:=
setIPv4MulticastLoopback
(
c
.
fd
,
false
)
if
err
!=
nil
{
if
err
:=
setIPv4MulticastLoopback
(
c
.
fd
,
false
);
err
!=
nil
{
return
err
}
err
=
joinIPv4GroupUDP
(
c
,
ifi
,
ip
)
if
err
!=
nil
{
if
err
:=
joinIPv4Group
(
c
.
fd
,
ifi
,
ip
);
err
!=
nil
{
return
err
}
return
nil
...
...
@@ -255,34 +249,15 @@ func listenIPv4MulticastUDP(c *UDPConn, ifi *Interface, ip IP) error {
func
listenIPv6MulticastUDP
(
c
*
UDPConn
,
ifi
*
Interface
,
ip
IP
)
error
{
if
ifi
!=
nil
{
err
:=
setIPv6MulticastInterface
(
c
.
fd
,
ifi
)
if
err
!=
nil
{
if
err
:=
setIPv6MulticastInterface
(
c
.
fd
,
ifi
);
err
!=
nil
{
return
err
}
}
err
:=
setIPv6MulticastLoopback
(
c
.
fd
,
false
)
if
err
!=
nil
{
if
err
:=
setIPv6MulticastLoopback
(
c
.
fd
,
false
);
err
!=
nil
{
return
err
}
err
=
joinIPv6GroupUDP
(
c
,
ifi
,
ip
)
if
err
!=
nil
{
if
err
:=
joinIPv6Group
(
c
.
fd
,
ifi
,
ip
);
err
!=
nil
{
return
err
}
return
nil
}
func
joinIPv4GroupUDP
(
c
*
UDPConn
,
ifi
*
Interface
,
ip
IP
)
error
{
err
:=
joinIPv4Group
(
c
.
fd
,
ifi
,
ip
)
if
err
!=
nil
{
return
&
OpError
{
"joinipv4group"
,
c
.
fd
.
net
,
&
IPAddr
{
IP
:
ip
},
err
}
}
return
nil
}
func
joinIPv6GroupUDP
(
c
*
UDPConn
,
ifi
*
Interface
,
ip
IP
)
error
{
err
:=
joinIPv6Group
(
c
.
fd
,
ifi
,
ip
)
if
err
!=
nil
{
return
&
OpError
{
"joinipv6group"
,
c
.
fd
.
net
,
&
IPAddr
{
IP
:
ip
},
err
}
}
return
nil
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment