(index<- ) ./libstd/rt/io/net/ip.rs
1 // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 use vec::MutableCloneableVector;
12 use to_str::ToStr;
13 use from_str::FromStr;
14 use option::{Option, None, Some};
15
16
17 pub type Port = u16;
18
19 #[deriving(Eq, TotalEq, Clone)]
20 pub enum IpAddr {
21 Ipv4Addr(u8, u8, u8, u8),
22 Ipv6Addr(u16, u16, u16, u16, u16, u16, u16, u16)
23 }
24
25 impl ToStr for IpAddr {
26 fn to_str(&self) -> ~str {
27 match *self {
28 Ipv4Addr(a, b, c, d) =>
29 format!("{}.{}.{}.{}", a, b, c, d),
30
31 // Ipv4 Compatible address
32 Ipv6Addr(0, 0, 0, 0, 0, 0, g, h) => {
33 format!("::{}.{}.{}.{}", (g >> 8) as u8, g as u8,
34 (h >> 8) as u8, h as u8)
35 }
36
37 // Ipv4-Mapped address
38 Ipv6Addr(0, 0, 0, 0, 0, 0xFFFF, g, h) => {
39 format!("::FFFF:{}.{}.{}.{}", (g >> 8) as u8, g as u8,
40 (h >> 8) as u8, h as u8)
41 }
42
43 Ipv6Addr(a, b, c, d, e, f, g, h) =>
44 format!("{}:{}:{}:{}:{}:{}:{}:{}", a, b, c, d, e, f, g, h)
45 }
46 }
47 }
48
49 #[deriving(Eq, TotalEq, Clone)]
50 pub struct SocketAddr {
51 ip: IpAddr,
52 port: Port,
53 }
54
55
56 impl ToStr for SocketAddr {
57 fn to_str(&self) -> ~str {
58 match self.ip {
59 Ipv4Addr(*) => format!("{}:{}", self.ip.to_str(), self.port),
60 Ipv6Addr(*) => format!("[{}]:{}", self.ip.to_str(), self.port),
61 }
62 }
63 }
64
65 struct Parser<'self> {
66 // parsing as ASCII, so can use byte array
67 s: &'self [u8],
68 pos: uint,
69 }
70
71 impl<'self> Parser<'self> {
72 fn new(s: &'self str) -> Parser<'self> {
73 Parser {
74 s: s.as_bytes(),
75 pos: 0,
76 }
77 }
78
79 fn is_eof(&self) -> bool {
80 self.pos == self.s.len()
81 }
82
83 // Commit only if parser returns Some
84 fn read_atomically<T>(&mut self, cb: &fn(&mut Parser) -> Option<T>) -> Option<T> {
85 let pos = self.pos;
86 let r = cb(self);
87 if r.is_none() {
88 self.pos = pos;
89 }
90 r
91 }
92
93 // Commit only if parser read till EOF
94 fn read_till_eof<T>(&mut self, cb: &fn(&mut Parser) -> Option<T>) -> Option<T> {
95 do self.read_atomically |p| {
96 cb(p).filtered(|_| p.is_eof())
97 }
98 }
99
100 // Return result of first successful parser
101 fn read_or<T>(&mut self, parsers: &[&fn(&mut Parser) -> Option<T>]) -> Option<T> {
102 for pf in parsers.iter() {
103 match self.read_atomically(|p: &mut Parser| (*pf)(p)) {
104 Some(r) => return Some(r),
105 None => {}
106 }
107 }
108 None
109 }
110
111 // Apply 3 parsers sequentially
112 fn read_seq_3<A, B, C>(&mut self,
113 pa: &fn(&mut Parser) -> Option<A>,
114 pb: &fn(&mut Parser) -> Option<B>,
115 pc: &fn(&mut Parser) -> Option<C>
116 ) -> Option<(A, B, C)>
117 {
118 do self.read_atomically |p| {
119 let a = pa(p);
120 let b = if a.is_some() { pb(p) } else { None };
121 let c = if b.is_some() { pc(p) } else { None };
122 match (a, b, c) {
123 (Some(a), Some(b), Some(c)) => Some((a, b, c)),
124 _ => None
125 }
126 }
127 }
128
129 // Read next char
130 fn read_char(&mut self) -> Option<char> {
131 if self.is_eof() {
132 None
133 } else {
134 let r = self.s[self.pos] as char;
135 self.pos += 1;
136 Some(r)
137 }
138 }
139
140 // Return char and advance iff next char is equal to requested
141 fn read_given_char(&mut self, c: char) -> Option<char> {
142 do self.read_atomically |p| {
143 p.read_char().filtered(|&next| next == c)
144 }
145 }
146
147 // Read digit
148 fn read_digit(&mut self, radix: u8) -> Option<u8> {
149 fn parse_digit(c: char, radix: u8) -> Option<u8> {
150 let c = c as u8;
151 // assuming radix is either 10 or 16
152 if c >= '0' as u8 && c <= '9' as u8 {
153 Some((c - '0' as u8) as u8)
154 } else if radix > 10 && c >= 'a' as u8 && c < 'a' as u8 + (radix - 10) {
155 Some((c - 'a' as u8 + 10) as u8)
156 } else if radix > 10 && c >= 'A' as u8 && c < 'A' as u8 + (radix - 10) {
157 Some((c - 'A' as u8 + 10) as u8)
158 } else {
159 None
160 }
161 }
162
163 do self.read_atomically |p| {
164 p.read_char().and_then(|c| parse_digit(c, radix))
165 }
166 }
167
168 fn read_number_impl(&mut self, radix: u8, max_digits: u32, upto: u32) -> Option<u32> {
169 let mut r = 0u32;
170 let mut digit_count = 0;
171 loop {
172 match self.read_digit(radix) {
173 Some(d) => {
174 r = r * (radix as u32) + (d as u32);
175 digit_count += 1;
176 if digit_count > max_digits || r >= upto {
177 return None
178 }
179 }
180 None => {
181 if digit_count == 0 {
182 return None
183 } else {
184 return Some(r)
185 }
186 }
187 };
188 }
189 }
190
191 // Read number, failing if max_digits of number value exceeded
192 fn read_number(&mut self, radix: u8, max_digits: u32, upto: u32) -> Option<u32> {
193 do self.read_atomically |p| {
194 p.read_number_impl(radix, max_digits, upto)
195 }
196 }
197
198 fn read_ipv4_addr_impl(&mut self) -> Option<IpAddr> {
199 let mut bs = [0u8, ..4];
200 let mut i = 0;
201 while i < 4 {
202 if i != 0 && self.read_given_char('.').is_none() {
203 return None;
204 }
205
206 let octet = self.read_number(10, 3, 0x100).map(|n| n as u8);
207 match octet {
208 Some(d) => bs[i] = d,
209 None => return None,
210 };
211 i += 1;
212 }
213 Some(Ipv4Addr(bs[0], bs[1], bs[2], bs[3]))
214 }
215
216 // Read IPv4 address
217 fn read_ipv4_addr(&mut self) -> Option<IpAddr> {
218 do self.read_atomically |p| {
219 p.read_ipv4_addr_impl()
220 }
221 }
222
223 fn read_ipv6_addr_impl(&mut self) -> Option<IpAddr> {
224 fn ipv6_addr_from_head_tail(head: &[u16], tail: &[u16]) -> IpAddr {
225 assert!(head.len() + tail.len() <= 8);
226 let mut gs = [0u16, ..8];
227 gs.copy_from(head);
228 gs.mut_slice(8 - tail.len(), 8).copy_from(tail);
229 Ipv6Addr(gs[0], gs[1], gs[2], gs[3], gs[4], gs[5], gs[6], gs[7])
230 }
231
232 fn read_groups(p: &mut Parser, groups: &mut [u16, ..8], limit: uint) -> (uint, bool) {
233 let mut i = 0;
234 while i < limit {
235 if i < limit - 1 {
236 let ipv4 = do p.read_atomically |p| {
237 if i == 0 || p.read_given_char(':').is_some() {
238 p.read_ipv4_addr()
239 } else {
240 None
241 }
242 };
243 match ipv4 {
244 Some(Ipv4Addr(a, b, c, d)) => {
245 groups[i + 0] = (a as u16 << 8) | (b as u16);
246 groups[i + 1] = (c as u16 << 8) | (d as u16);
247 return (i + 2, true);
248 }
249 _ => {}
250 }
251 }
252
253 let group = do p.read_atomically |p| {
254 if i == 0 || p.read_given_char(':').is_some() {
255 p.read_number(16, 4, 0x10000).map(|n| n as u16)
256 } else {
257 None
258 }
259 };
260 match group {
261 Some(g) => groups[i] = g,
262 None => return (i, false)
263 }
264 i += 1;
265 }
266 (i, false)
267 }
268
269 let mut head = [0u16, ..8];
270 let (head_size, head_ipv4) = read_groups(self, &mut head, 8);
271
272 if head_size == 8 {
273 return Some(Ipv6Addr(
274 head[0], head[1], head[2], head[3],
275 head[4], head[5], head[6], head[7]))
276 }
277
278 // IPv4 part is not allowed before `::`
279 if head_ipv4 {
280 return None
281 }
282
283 // read `::` if previous code parsed less than 8 groups
284 if !self.read_given_char(':').is_some() || !self.read_given_char(':').is_some() {
285 return None;
286 }
287
288 let mut tail = [0u16, ..8];
289 let (tail_size, _) = read_groups(self, &mut tail, 8 - head_size);
290 Some(ipv6_addr_from_head_tail(head.slice(0, head_size), tail.slice(0, tail_size)))
291 }
292
293 fn read_ipv6_addr(&mut self) -> Option<IpAddr> {
294 do self.read_atomically |p| {
295 p.read_ipv6_addr_impl()
296 }
297 }
298
299 fn read_ip_addr(&mut self) -> Option<IpAddr> {
300 let ipv4_addr = |p: &mut Parser| p.read_ipv4_addr();
301 let ipv6_addr = |p: &mut Parser| p.read_ipv6_addr();
302 self.read_or([ipv4_addr, ipv6_addr])
303 }
304
305 fn read_socket_addr(&mut self) -> Option<SocketAddr> {
306 let ip_addr = |p: &mut Parser| {
307 let ipv4_p = |p: &mut Parser| p.read_ip_addr();
308 let ipv6_p = |p: &mut Parser| {
309 let open_br = |p: &mut Parser| p.read_given_char('[');
310 let ip_addr = |p: &mut Parser| p.read_ipv6_addr();
311 let clos_br = |p: &mut Parser| p.read_given_char(']');
312 p.read_seq_3::<char, IpAddr, char>(open_br, ip_addr, clos_br)
313 .map(|t| match t { (_, ip, _) => ip })
314 };
315 p.read_or([ipv4_p, ipv6_p])
316 };
317 let colon = |p: &mut Parser| p.read_given_char(':');
318 let port = |p: &mut Parser| p.read_number(10, 5, 0x10000).map(|n| n as u16);
319
320 // host, colon, port
321 self.read_seq_3::<IpAddr, char, u16>(ip_addr, colon, port)
322 .map(|t| match t { (ip, _, port) => SocketAddr { ip: ip, port: port } })
323 }
324 }
325
326 impl FromStr for IpAddr {
327 fn from_str(s: &str) -> Option<IpAddr> {
328 do Parser::new(s).read_till_eof |p| {
329 p.read_ip_addr()
330 }
331 }
332 }
333
334 impl FromStr for SocketAddr {
335 fn from_str(s: &str) -> Option<SocketAddr> {
336 do Parser::new(s).read_till_eof |p| {
337 p.read_socket_addr()
338 }
339 }
340 }
341
342
343 #[cfg(test)]
344 mod test {
345 use super::*;
346 use from_str::FromStr;
347 use option::{Option, Some, None};
348
349 #[test]
350 fn test_from_str_ipv4() {
351 assert_eq!(Some(Ipv4Addr(127, 0, 0, 1)), FromStr::from_str("127.0.0.1"));
352 assert_eq!(Some(Ipv4Addr(255, 255, 255, 255)), FromStr::from_str("255.255.255.255"));
353 assert_eq!(Some(Ipv4Addr(0, 0, 0, 0)), FromStr::from_str("0.0.0.0"));
354
355 // out of range
356 let none: Option<IpAddr> = FromStr::from_str("256.0.0.1");
357 assert_eq!(None, none);
358 // too short
359 let none: Option<IpAddr> = FromStr::from_str("255.0.0");
360 assert_eq!(None, none);
361 // too long
362 let none: Option<IpAddr> = FromStr::from_str("255.0.0.1.2");
363 assert_eq!(None, none);
364 // no number between dots
365 let none: Option<IpAddr> = FromStr::from_str("255.0..1");
366 assert_eq!(None, none);
367 }
368
369 #[test]
370 fn test_from_str_ipv6() {
371 assert_eq!(Some(Ipv6Addr(0, 0, 0, 0, 0, 0, 0, 0)), FromStr::from_str("0:0:0:0:0:0:0:0"));
372 assert_eq!(Some(Ipv6Addr(0, 0, 0, 0, 0, 0, 0, 1)), FromStr::from_str("0:0:0:0:0:0:0:1"));
373
374 assert_eq!(Some(Ipv6Addr(0, 0, 0, 0, 0, 0, 0, 1)), FromStr::from_str("::1"));
375 assert_eq!(Some(Ipv6Addr(0, 0, 0, 0, 0, 0, 0, 0)), FromStr::from_str("::"));
376
377 assert_eq!(Some(Ipv6Addr(0x2a02, 0x6b8, 0, 0, 0, 0, 0x11, 0x11)),
378 FromStr::from_str("2a02:6b8::11:11"));
379
380 // too long group
381 let none: Option<IpAddr> = FromStr::from_str("::00000");
382 assert_eq!(None, none);
383 // too short
384 let none: Option<IpAddr> = FromStr::from_str("1:2:3:4:5:6:7");
385 assert_eq!(None, none);
386 // too long
387 let none: Option<IpAddr> = FromStr::from_str("1:2:3:4:5:6:7:8:9");
388 assert_eq!(None, none);
389 // triple colon
390 let none: Option<IpAddr> = FromStr::from_str("1:2:::6:7:8");
391 assert_eq!(None, none);
392 // two double colons
393 let none: Option<IpAddr> = FromStr::from_str("1:2::6::8");
394 assert_eq!(None, none);
395 }
396
397 #[test]
398 fn test_from_str_ipv4_in_ipv6() {
399 assert_eq!(Some(Ipv6Addr(0, 0, 0, 0, 0, 0, 49152, 545)),
400 FromStr::from_str("::192.0.2.33"));
401 assert_eq!(Some(Ipv6Addr(0, 0, 0, 0, 0, 0xFFFF, 49152, 545)),
402 FromStr::from_str("::FFFF:192.0.2.33"));
403 assert_eq!(Some(Ipv6Addr(0x64, 0xff9b, 0, 0, 0, 0, 49152, 545)),
404 FromStr::from_str("64:ff9b::192.0.2.33"));
405 assert_eq!(Some(Ipv6Addr(0x2001, 0xdb8, 0x122, 0xc000, 0x2, 0x2100, 49152, 545)),
406 FromStr::from_str("2001:db8:122:c000:2:2100:192.0.2.33"));
407
408 // colon after v4
409 let none: Option<IpAddr> = FromStr::from_str("::127.0.0.1:");
410 assert_eq!(None, none);
411 // not enought groups
412 let none: Option<IpAddr> = FromStr::from_str("1.2.3.4.5:127.0.0.1");
413 assert_eq!(None, none);
414 // too many groups
415 let none: Option<IpAddr> =
416 FromStr::from_str("1.2.3.4.5:6:7:127.0.0.1");
417 assert_eq!(None, none);
418 }
419
420 #[test]
421 fn test_from_str_socket_addr() {
422 assert_eq!(Some(SocketAddr { ip: Ipv4Addr(77, 88, 21, 11), port: 80 }),
423 FromStr::from_str("77.88.21.11:80"));
424 assert_eq!(Some(SocketAddr { ip: Ipv6Addr(0x2a02, 0x6b8, 0, 1, 0, 0, 0, 1), port: 53 }),
425 FromStr::from_str("[2a02:6b8:0:1::1]:53"));
426 assert_eq!(Some(SocketAddr { ip: Ipv6Addr(0, 0, 0, 0, 0, 0, 0x7F00, 1), port: 22 }),
427 FromStr::from_str("[::127.0.0.1]:22"));
428
429 // without port
430 let none: Option<SocketAddr> = FromStr::from_str("127.0.0.1");
431 assert_eq!(None, none);
432 // without port
433 let none: Option<SocketAddr> = FromStr::from_str("127.0.0.1:");
434 assert_eq!(None, none);
435 // wrong brackets around v4
436 let none: Option<SocketAddr> = FromStr::from_str("[127.0.0.1]:22");
437 assert_eq!(None, none);
438 // port out of range
439 let none: Option<SocketAddr> = FromStr::from_str("127.0.0.1:123456");
440 assert_eq!(None, none);
441 }
442
443 #[test]
444 fn ipv6_addr_to_str() {
445 let a1 = Ipv6Addr(0, 0, 0, 0, 0, 0xffff, 0xc000, 0x280);
446 assert!(a1.to_str() == ~"::ffff:192.0.2.128" || a1.to_str() == ~"::FFFF:192.0.2.128");
447 }
448
449 }
libstd/rt/io/net/ip.rs:224:8-224:8 -fn- definition:
fn ipv6_addr_from_head_tail(head: &[u16], tail: &[u16]) -> IpAddr {
assert!(head.len() + tail.len() <= 8);
references:-290: Some(ipv6_addr_from_head_tail(head.slice(0, head_size), tail.slice(0, tail_size)))
libstd/rt/io/net/ip.rs:16:1-16:1 -ty- definition:
pub type Port = u16;
references:-52: port: Port,
libstd/rt/io/net/ip.rs:149:8-149:8 -fn- definition:
fn parse_digit(c: char, radix: u8) -> Option<u8> {
let c = c as u8;
references:-164: p.read_char().and_then(|c| parse_digit(c, radix))
libstd/rt/io/net/ip.rs:64:1-64:1 -struct- definition:
struct Parser<'self> {
references:-310: let ip_addr = |p: &mut Parser| p.read_ipv6_addr();
114: pb: &fn(&mut Parser) -> Option<B>,
72: fn new(s: &'self str) -> Parser<'self> {
301: let ipv6_addr = |p: &mut Parser| p.read_ipv6_addr();
318: let port = |p: &mut Parser| p.read_number(10, 5, 0x10000).map(|n| n as u16);
113: pa: &fn(&mut Parser) -> Option<A>,
308: let ipv6_p = |p: &mut Parser| {
101: fn read_or<T>(&mut self, parsers: &[&fn(&mut Parser) -> Option<T>]) -> Option<T> {
71: impl<'self> Parser<'self> {
84: fn read_atomically<T>(&mut self, cb: &fn(&mut Parser) -> Option<T>) -> Option<T> {
307: let ipv4_p = |p: &mut Parser| p.read_ip_addr();
300: let ipv4_addr = |p: &mut Parser| p.read_ipv4_addr();
306: let ip_addr = |p: &mut Parser| {
115: pc: &fn(&mut Parser) -> Option<C>
73: Parser {
309: let open_br = |p: &mut Parser| p.read_given_char('[');
317: let colon = |p: &mut Parser| p.read_given_char(':');
232: fn read_groups(p: &mut Parser, groups: &mut [u16, ..8], limit: uint) -> (uint, bool) {
94: fn read_till_eof<T>(&mut self, cb: &fn(&mut Parser) -> Option<T>) -> Option<T> {
103: match self.read_atomically(|p: &mut Parser| (*pf)(p)) {
311: let clos_br = |p: &mut Parser| p.read_given_char(']');
libstd/rt/io/net/ip.rs:232:8-232:8 -fn- definition:
fn read_groups(p: &mut Parser, groups: &mut [u16, ..8], limit: uint) -> (uint, bool) {
let mut i = 0;
references:-270: let (head_size, head_ipv4) = read_groups(self, &mut head, 8);
289: let (tail_size, _) = read_groups(self, &mut tail, 8 - head_size);
libstd/rt/io/net/ip.rs:19:32-19:32 -enum- definition:
#[deriving(Eq, TotalEq, Clone)]
pub enum IpAddr {
references:-19: #[deriving(Eq, TotalEq, Clone)]
25: impl ToStr for IpAddr {
217: fn read_ipv4_addr(&mut self) -> Option<IpAddr> {
19: #[deriving(Eq, TotalEq, Clone)]
19: #[deriving(Eq, TotalEq, Clone)]
224: fn ipv6_addr_from_head_tail(head: &[u16], tail: &[u16]) -> IpAddr {
326: impl FromStr for IpAddr {
321: self.read_seq_3::<IpAddr, char, u16>(ip_addr, colon, port)
198: fn read_ipv4_addr_impl(&mut self) -> Option<IpAddr> {
327: fn from_str(s: &str) -> Option<IpAddr> {
293: fn read_ipv6_addr(&mut self) -> Option<IpAddr> {
223: fn read_ipv6_addr_impl(&mut self) -> Option<IpAddr> {
19: #[deriving(Eq, TotalEq, Clone)]
19: #[deriving(Eq, TotalEq, Clone)]
299: fn read_ip_addr(&mut self) -> Option<IpAddr> {
19: #[deriving(Eq, TotalEq, Clone)]
19: #[deriving(Eq, TotalEq, Clone)]
312: p.read_seq_3::<char, IpAddr, char>(open_br, ip_addr, clos_br)
51: ip: IpAddr,
libstd/rt/rtio.rs:
81: fn get_host_addresses(&mut self, host: &str) -> Result<~[IpAddr], IoError>;
121: fn leave_multicast(&mut self, multi: IpAddr) -> Result<(), IoError>;
120: fn join_multicast(&mut self, multi: IpAddr) -> Result<(), IoError>;
libstd/rt/uv/uvio.rs:
660: let result_cell_ptr: *Cell<Result<~[IpAddr], IoError>> = &result_cell;
1235: fn join_multicast(&mut self, multi: IpAddr) -> Result<(), IoError> {
1251: fn leave_multicast(&mut self, multi: IpAddr) -> Result<(), IoError> {
658: fn get_host_addresses(&mut self, host: &str) -> Result<~[IpAddr], IoError> {
libstd/rt/io/net/mod.rs:
25: pub fn get_host_addresses(host: &str) -> Option<~[IpAddr]> {
libstd/rt/io/net/ip.rs:49:32-49:32 -struct- definition:
#[deriving(Eq, TotalEq, Clone)]
pub struct SocketAddr {
references:-49: #[deriving(Eq, TotalEq, Clone)]
49: #[deriving(Eq, TotalEq, Clone)]
49: #[deriving(Eq, TotalEq, Clone)]
305: fn read_socket_addr(&mut self) -> Option<SocketAddr> {
49: #[deriving(Eq, TotalEq, Clone)]
49: #[deriving(Eq, TotalEq, Clone)]
334: impl FromStr for SocketAddr {
49: #[deriving(Eq, TotalEq, Clone)]
49: #[deriving(Eq, TotalEq, Clone)]
49: #[deriving(Eq, TotalEq, Clone)]
322: .map(|t| match t { (ip, _, port) => SocketAddr { ip: ip, port: port } })
49: #[deriving(Eq, TotalEq, Clone)]
56: impl ToStr for SocketAddr {
49: #[deriving(Eq, TotalEq, Clone)]
49: #[deriving(Eq, TotalEq, Clone)]
49: #[deriving(Eq, TotalEq, Clone)]
49: #[deriving(Eq, TotalEq, Clone)]
49: #[deriving(Eq, TotalEq, Clone)]
335: fn from_str(s: &str) -> Option<SocketAddr> {
49: #[deriving(Eq, TotalEq, Clone)]
libstd/rt/rtio.rs:
118: fn sendto(&mut self, buf: &[u8], dst: SocketAddr) -> Result<(), IoError>;
75: fn udp_bind(&mut self, addr: SocketAddr) -> Result<~RtioUdpSocketObject, IoError>;
74: fn tcp_bind(&mut self, addr: SocketAddr) -> Result<~RtioTcpListenerObject, IoError>;
73: fn tcp_connect(&mut self, addr: SocketAddr) -> Result<~RtioTcpStreamObject, IoError>;
117: fn recvfrom(&mut self, buf: &mut [u8]) -> Result<(uint, SocketAddr), IoError>;
113: fn socket_name(&mut self) -> Result<SocketAddr, IoError>;
105: fn peer_name(&mut self) -> Result<SocketAddr, IoError>;
libstd/rt/uv/mod.rs:
138: pub type UdpReceiveCallback = ~fn(UdpWatcher, int, Buf, SocketAddr, uint, Option<UvError>);
libstd/rt/uv/uvio.rs:
1066: fn socket_name(&mut self) -> Result<SocketAddr, IoError> {
1174: fn recvfrom(&mut self, buf: &mut [u8]) -> Result<(uint, SocketAddr), IoError> {
(147)(1208)(519)(449)(1166)(1177)(496)(1086)(833)(881)libstd/rt/uv/net.rs:
(407)(42)(94)(100)(274)(64)(354)(259)(91)libstd/rt/test.rs:
(336)(337)(332)(331)libstd/rt/io/net/tcp.rs:
(120)(106)(61)(50)(32)libstd/rt/io/net/udp.rs:
(62)(58)(24)(51)(76)(38)