Skip to content

Commit 8f2410d

Browse files
committed
---
yaml --- r: 158700 b: refs/heads/snap-stage3 c: ac84674 h: refs/heads/master v: v3
1 parent d4590a6 commit 8f2410d

File tree

3 files changed

+131
-228
lines changed

3 files changed

+131
-228
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 0b48001c28329392b26961eaf1c3ed293a352d6f
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: d97bfb22f8c4958909c5669c256c50f124c17d58
4+
refs/heads/snap-stage3: ac846749f0abbd0b6107406ba2f97886605e1ad4
55
refs/heads/try: f58aad6dce273570fb130b4df008ef9acd5a5be2
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d

branches/snap-stage3/src/libstd/io/net/mod.rs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@
1010

1111
//! Networking I/O
1212
13+
use io::{IoError, InvalidInput};
14+
use option::None;
15+
use result::{Result, Ok, Err};
1316
use rt::rtio;
14-
use self::ip::{Ipv4Addr, Ipv6Addr, IpAddr};
17+
use self::ip::{Ipv4Addr, Ipv6Addr, IpAddr, ToSocketAddr};
1518

1619
pub use self::addrinfo::get_host_addresses;
1720

@@ -38,3 +41,25 @@ fn from_rtio(ip: rtio::IpAddr) -> IpAddr {
3841
}
3942
}
4043
}
44+
45+
fn with_addresses<A: ToSocketAddr, T>(
46+
addr: A,
47+
action: |&mut rtio::IoFactory, rtio::SocketAddr| -> Result<T, rtio::IoError>
48+
) -> Result<T, IoError> {
49+
const DEFAULT_ERROR: IoError = IoError {
50+
kind: InvalidInput,
51+
desc: "no addresses found for hostname",
52+
detail: None
53+
};
54+
55+
let addresses = try!(addr.to_socket_addr_all());
56+
let mut err = DEFAULT_ERROR;
57+
for addr in addresses.into_iter() {
58+
let addr = rtio::SocketAddr { ip: to_rtio(addr.ip), port: addr.port };
59+
match rtio::LocalIo::maybe_raise(|io| action(io, addr)) {
60+
Ok(r) => return Ok(r),
61+
Err(e) => err = IoError::from_rtio_error(e)
62+
}
63+
}
64+
Err(err)
65+
}

0 commit comments

Comments
 (0)