LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // UDP sockets for Plan 9 | 5 // UDP sockets for Plan 9 |
6 | 6 |
7 package net | 7 package net |
8 | 8 |
9 import ( | 9 import ( |
10 "errors" | 10 "errors" |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 // address laddr. The returned connection c's ReadFrom and WriteTo | 177 // address laddr. The returned connection c's ReadFrom and WriteTo |
178 // methods can be used to receive and send UDP packets with per-packet | 178 // methods can be used to receive and send UDP packets with per-packet |
179 // addressing. | 179 // addressing. |
180 func ListenUDP(net string, laddr *UDPAddr) (c *UDPConn, err error) { | 180 func ListenUDP(net string, laddr *UDPAddr) (c *UDPConn, err error) { |
181 switch net { | 181 switch net { |
182 case "udp", "udp4", "udp6": | 182 case "udp", "udp4", "udp6": |
183 default: | 183 default: |
184 return nil, UnknownNetworkError(net) | 184 return nil, UnknownNetworkError(net) |
185 } | 185 } |
186 if laddr == nil { | 186 if laddr == nil { |
187 » » return nil, &OpError{"listen", net, nil, errMissingAddress} | 187 » » laddr = &UDPAddr{} |
188 } | 188 } |
189 l, err := listenPlan9(net, laddr) | 189 l, err := listenPlan9(net, laddr) |
190 if err != nil { | 190 if err != nil { |
191 return | 191 return |
192 } | 192 } |
193 _, err = l.ctl.WriteString("headers") | 193 _, err = l.ctl.WriteString("headers") |
194 if err != nil { | 194 if err != nil { |
195 return | 195 return |
196 } | 196 } |
197 return &UDPConn{*l.plan9Conn()}, nil | 197 return &UDPConn{*l.plan9Conn()}, nil |
198 } | 198 } |
199 | 199 |
200 // ListenMulticastUDP listens for incoming multicast UDP packets | 200 // ListenMulticastUDP listens for incoming multicast UDP packets |
201 // addressed to the group address gaddr on ifi, which specifies the | 201 // addressed to the group address gaddr on ifi, which specifies the |
202 // interface to join. ListenMulticastUDP uses default multicast | 202 // interface to join. ListenMulticastUDP uses default multicast |
203 // interface if ifi is nil. | 203 // interface if ifi is nil. |
204 func ListenMulticastUDP(net string, ifi *Interface, gaddr *UDPAddr) (*UDPConn, e
rror) { | 204 func ListenMulticastUDP(net string, ifi *Interface, gaddr *UDPAddr) (*UDPConn, e
rror) { |
205 return nil, syscall.EPLAN9 | 205 return nil, syscall.EPLAN9 |
206 } | 206 } |
LEFT | RIGHT |