2015-02-06 00:50:11 +00:00
|
|
|
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2015-04-28 15:18:10 +00:00
|
|
|
//! Networking primitives for TCP/UDP communication.
|
2017-03-26 15:27:40 +00:00
|
|
|
//!
|
|
|
|
//! This module provides networking functionality for the Transmission Control and User
|
|
|
|
//! Datagram Protocols, as well as types for IP and socket addresses.
|
|
|
|
//!
|
|
|
|
//! # Organization
|
|
|
|
//!
|
|
|
|
//! * [`TcpListener`] and [`TcpStream`] provide functionality for communication over TCP
|
|
|
|
//! * [`UdpSocket`] provides functionality for communication over UDP
|
|
|
|
//! * [`IpAddr`] represents IP addresses of either IPv4 or IPv6; [`Ipv4Addr`] and
|
|
|
|
//! [`Ipv6Addr`] are respectively IPv4 and IPv6 addresses
|
|
|
|
//! * [`SocketAddr`] represents socket addresses of either IPv4 or IPv6; [`SocketAddrV4`]
|
|
|
|
//! and [`SocketAddrV6`] are respectively IPv4 and IPv6 socket addresses
|
2017-03-27 14:38:17 +00:00
|
|
|
//! * [`ToSocketAddrs`] is a trait that used for generic address resolution when interacting
|
2017-03-26 15:27:40 +00:00
|
|
|
//! with networking objects like [`TcpListener`], [`TcpStream`] or [`UdpSocket`]
|
|
|
|
//! * Other types are return or parameter types for various methods in this module
|
|
|
|
//!
|
|
|
|
//! [`IpAddr`]: ../../std/net/enum.IpAddr.html
|
|
|
|
//! [`Ipv4Addr`]: ../../std/net/struct.Ipv4Addr.html
|
|
|
|
//! [`Ipv6Addr`]: ../../std/net/struct.Ipv6Addr.html
|
|
|
|
//! [`SocketAddr`]: ../../std/net/enum.SocketAddr.html
|
|
|
|
//! [`SocketAddrV4`]: ../../std/net/struct.SocketAddrV4.html
|
|
|
|
//! [`SocketAddrV6`]: ../../std/net/struct.SocketAddrV6.html
|
|
|
|
//! [`TcpListener`]: ../../std/net/struct.TcpListener.html
|
|
|
|
//! [`TcpStream`]: ../../std/net/struct.TcpStream.html
|
2017-03-27 14:38:17 +00:00
|
|
|
//! [`ToSocketAddrs`]: ../../std/net/trait.ToSocketAddrs.html
|
2017-03-26 15:27:40 +00:00
|
|
|
//! [`UdpSocket`]: ../../std/net/struct.UdpSocket.html
|
2015-02-06 00:50:11 +00:00
|
|
|
|
std: Stabilize the `net` module
This commit performs a stabilization pass over the std::net module,
incorporating the changes from RFC 923. Specifically, the following actions were
taken:
Stable functionality:
* `net` (the name)
* `Shutdown`
* `Shutdown::{Read, Write, Both}`
* `lookup_host`
* `LookupHost`
* `SocketAddr`
* `SocketAddr::{V4, V6}`
* `SocketAddr::port`
* `SocketAddrV4`
* `SocketAddrV4::{new, ip, port}`
* `SocketAddrV6`
* `SocketAddrV4::{new, ip, port, flowinfo, scope_id}`
* Common trait impls for socket addr structures
* `ToSocketAddrs`
* `ToSocketAddrs::Iter`
* `ToSocketAddrs::to_socket_addrs`
* `ToSocketAddrs for {SocketAddr*, (Ipv*Addr, u16), str, (str, u16)}`
* `Ipv4Addr`
* `Ipv4Addr::{new, octets, to_ipv6_compatible, to_ipv6_mapped}`
* `Ipv6Addr`
* `Ipv6Addr::{new, segments, to_ipv4}`
* `TcpStream`
* `TcpStream::connect`
* `TcpStream::{peer_addr, local_addr, shutdown, try_clone}`
* `{Read,Write} for {TcpStream, &TcpStream}`
* `TcpListener`
* `TcpListener::bind`
* `TcpListener::{local_addr, try_clone, accept, incoming}`
* `Incoming`
* `UdpSocket`
* `UdpSocket::bind`
* `UdpSocket::{recv_from, send_to, local_addr, try_clone}`
Unstable functionality:
* Extra methods on `Ipv{4,6}Addr` for various methods of inspecting the address
and determining qualities of it.
* Extra methods on `TcpStream` to configure various protocol options.
* Extra methods on `UdpSocket` to configure various protocol options.
Deprecated functionality:
* The `socket_addr` method has been renamed to `local_addr`
This commit is a breaking change due to the restructuring of the `SocketAddr`
type as well as the renaming of the `socket_addr` method. Migration should be
fairly straightforward, however, after accounting for the new level of
abstraction in `SocketAddr` (protocol distinction at the socket address level,
not the IP address).
[breaking-change]
2015-03-13 21:22:33 +00:00
|
|
|
#![stable(feature = "rust1", since = "1.0.0")]
|
2015-02-06 00:50:11 +00:00
|
|
|
|
|
|
|
use io::{self, Error, ErrorKind};
|
|
|
|
|
2015-11-16 16:54:28 +00:00
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
2015-03-25 19:30:49 +00:00
|
|
|
pub use self::ip::{IpAddr, Ipv4Addr, Ipv6Addr, Ipv6MulticastScope};
|
2015-11-16 16:54:28 +00:00
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
std: Stabilize the `net` module
This commit performs a stabilization pass over the std::net module,
incorporating the changes from RFC 923. Specifically, the following actions were
taken:
Stable functionality:
* `net` (the name)
* `Shutdown`
* `Shutdown::{Read, Write, Both}`
* `lookup_host`
* `LookupHost`
* `SocketAddr`
* `SocketAddr::{V4, V6}`
* `SocketAddr::port`
* `SocketAddrV4`
* `SocketAddrV4::{new, ip, port}`
* `SocketAddrV6`
* `SocketAddrV4::{new, ip, port, flowinfo, scope_id}`
* Common trait impls for socket addr structures
* `ToSocketAddrs`
* `ToSocketAddrs::Iter`
* `ToSocketAddrs::to_socket_addrs`
* `ToSocketAddrs for {SocketAddr*, (Ipv*Addr, u16), str, (str, u16)}`
* `Ipv4Addr`
* `Ipv4Addr::{new, octets, to_ipv6_compatible, to_ipv6_mapped}`
* `Ipv6Addr`
* `Ipv6Addr::{new, segments, to_ipv4}`
* `TcpStream`
* `TcpStream::connect`
* `TcpStream::{peer_addr, local_addr, shutdown, try_clone}`
* `{Read,Write} for {TcpStream, &TcpStream}`
* `TcpListener`
* `TcpListener::bind`
* `TcpListener::{local_addr, try_clone, accept, incoming}`
* `Incoming`
* `UdpSocket`
* `UdpSocket::bind`
* `UdpSocket::{recv_from, send_to, local_addr, try_clone}`
Unstable functionality:
* Extra methods on `Ipv{4,6}Addr` for various methods of inspecting the address
and determining qualities of it.
* Extra methods on `TcpStream` to configure various protocol options.
* Extra methods on `UdpSocket` to configure various protocol options.
Deprecated functionality:
* The `socket_addr` method has been renamed to `local_addr`
This commit is a breaking change due to the restructuring of the `SocketAddr`
type as well as the renaming of the `socket_addr` method. Migration should be
fairly straightforward, however, after accounting for the new level of
abstraction in `SocketAddr` (protocol distinction at the socket address level,
not the IP address).
[breaking-change]
2015-03-13 21:22:33 +00:00
|
|
|
pub use self::addr::{SocketAddr, SocketAddrV4, SocketAddrV6, ToSocketAddrs};
|
2015-11-16 16:54:28 +00:00
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
2015-05-17 05:24:13 +00:00
|
|
|
pub use self::tcp::{TcpStream, TcpListener, Incoming};
|
2015-11-16 16:54:28 +00:00
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
2015-02-06 00:50:11 +00:00
|
|
|
pub use self::udp::UdpSocket;
|
2015-11-16 16:54:28 +00:00
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
2015-03-19 03:08:15 +00:00
|
|
|
pub use self::parser::AddrParseError;
|
2015-02-06 00:50:11 +00:00
|
|
|
|
|
|
|
mod ip;
|
|
|
|
mod addr;
|
|
|
|
mod tcp;
|
|
|
|
mod udp;
|
|
|
|
mod parser;
|
2016-09-22 01:30:30 +00:00
|
|
|
#[cfg(test)]
|
2016-09-14 17:10:43 +00:00
|
|
|
mod test;
|
2015-02-06 00:50:11 +00:00
|
|
|
|
2016-08-02 00:21:08 +00:00
|
|
|
/// Possible values which can be passed to the [`shutdown`] method of
|
|
|
|
/// [`TcpStream`].
|
|
|
|
///
|
|
|
|
/// [`shutdown`]: struct.TcpStream.html#method.shutdown
|
|
|
|
/// [`TcpStream`]: struct.TcpStream.html
|
2016-09-12 19:37:41 +00:00
|
|
|
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
|
std: Stabilize the `net` module
This commit performs a stabilization pass over the std::net module,
incorporating the changes from RFC 923. Specifically, the following actions were
taken:
Stable functionality:
* `net` (the name)
* `Shutdown`
* `Shutdown::{Read, Write, Both}`
* `lookup_host`
* `LookupHost`
* `SocketAddr`
* `SocketAddr::{V4, V6}`
* `SocketAddr::port`
* `SocketAddrV4`
* `SocketAddrV4::{new, ip, port}`
* `SocketAddrV6`
* `SocketAddrV4::{new, ip, port, flowinfo, scope_id}`
* Common trait impls for socket addr structures
* `ToSocketAddrs`
* `ToSocketAddrs::Iter`
* `ToSocketAddrs::to_socket_addrs`
* `ToSocketAddrs for {SocketAddr*, (Ipv*Addr, u16), str, (str, u16)}`
* `Ipv4Addr`
* `Ipv4Addr::{new, octets, to_ipv6_compatible, to_ipv6_mapped}`
* `Ipv6Addr`
* `Ipv6Addr::{new, segments, to_ipv4}`
* `TcpStream`
* `TcpStream::connect`
* `TcpStream::{peer_addr, local_addr, shutdown, try_clone}`
* `{Read,Write} for {TcpStream, &TcpStream}`
* `TcpListener`
* `TcpListener::bind`
* `TcpListener::{local_addr, try_clone, accept, incoming}`
* `Incoming`
* `UdpSocket`
* `UdpSocket::bind`
* `UdpSocket::{recv_from, send_to, local_addr, try_clone}`
Unstable functionality:
* Extra methods on `Ipv{4,6}Addr` for various methods of inspecting the address
and determining qualities of it.
* Extra methods on `TcpStream` to configure various protocol options.
* Extra methods on `UdpSocket` to configure various protocol options.
Deprecated functionality:
* The `socket_addr` method has been renamed to `local_addr`
This commit is a breaking change due to the restructuring of the `SocketAddr`
type as well as the renaming of the `socket_addr` method. Migration should be
fairly straightforward, however, after accounting for the new level of
abstraction in `SocketAddr` (protocol distinction at the socket address level,
not the IP address).
[breaking-change]
2015-03-13 21:22:33 +00:00
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
2015-02-06 00:50:11 +00:00
|
|
|
pub enum Shutdown {
|
2017-03-26 14:12:27 +00:00
|
|
|
/// The reading portion of the [`TcpStream`] should be shut down.
|
|
|
|
///
|
|
|
|
/// All currently blocked and future [reads] will return [`Ok(0)`].
|
|
|
|
///
|
|
|
|
/// [`TcpStream`]: ../../std/net/struct.TcpStream.html
|
|
|
|
/// [reads]: ../../std/io/trait.Read.html
|
|
|
|
/// [`Ok(0)`]: ../../std/result/enum.Result.html#variant.Ok
|
std: Stabilize the `net` module
This commit performs a stabilization pass over the std::net module,
incorporating the changes from RFC 923. Specifically, the following actions were
taken:
Stable functionality:
* `net` (the name)
* `Shutdown`
* `Shutdown::{Read, Write, Both}`
* `lookup_host`
* `LookupHost`
* `SocketAddr`
* `SocketAddr::{V4, V6}`
* `SocketAddr::port`
* `SocketAddrV4`
* `SocketAddrV4::{new, ip, port}`
* `SocketAddrV6`
* `SocketAddrV4::{new, ip, port, flowinfo, scope_id}`
* Common trait impls for socket addr structures
* `ToSocketAddrs`
* `ToSocketAddrs::Iter`
* `ToSocketAddrs::to_socket_addrs`
* `ToSocketAddrs for {SocketAddr*, (Ipv*Addr, u16), str, (str, u16)}`
* `Ipv4Addr`
* `Ipv4Addr::{new, octets, to_ipv6_compatible, to_ipv6_mapped}`
* `Ipv6Addr`
* `Ipv6Addr::{new, segments, to_ipv4}`
* `TcpStream`
* `TcpStream::connect`
* `TcpStream::{peer_addr, local_addr, shutdown, try_clone}`
* `{Read,Write} for {TcpStream, &TcpStream}`
* `TcpListener`
* `TcpListener::bind`
* `TcpListener::{local_addr, try_clone, accept, incoming}`
* `Incoming`
* `UdpSocket`
* `UdpSocket::bind`
* `UdpSocket::{recv_from, send_to, local_addr, try_clone}`
Unstable functionality:
* Extra methods on `Ipv{4,6}Addr` for various methods of inspecting the address
and determining qualities of it.
* Extra methods on `TcpStream` to configure various protocol options.
* Extra methods on `UdpSocket` to configure various protocol options.
Deprecated functionality:
* The `socket_addr` method has been renamed to `local_addr`
This commit is a breaking change due to the restructuring of the `SocketAddr`
type as well as the renaming of the `socket_addr` method. Migration should be
fairly straightforward, however, after accounting for the new level of
abstraction in `SocketAddr` (protocol distinction at the socket address level,
not the IP address).
[breaking-change]
2015-03-13 21:22:33 +00:00
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
2015-02-06 00:50:11 +00:00
|
|
|
Read,
|
2017-03-26 14:12:27 +00:00
|
|
|
/// The writing portion of the [`TcpStream`] should be shut down.
|
|
|
|
///
|
|
|
|
/// All currently blocked and future [writes] will return an error.
|
|
|
|
///
|
|
|
|
/// [`TcpStream`]: ../../std/net/struct.TcpStream.html
|
|
|
|
/// [writes]: ../../std/io/trait.Write.html
|
std: Stabilize the `net` module
This commit performs a stabilization pass over the std::net module,
incorporating the changes from RFC 923. Specifically, the following actions were
taken:
Stable functionality:
* `net` (the name)
* `Shutdown`
* `Shutdown::{Read, Write, Both}`
* `lookup_host`
* `LookupHost`
* `SocketAddr`
* `SocketAddr::{V4, V6}`
* `SocketAddr::port`
* `SocketAddrV4`
* `SocketAddrV4::{new, ip, port}`
* `SocketAddrV6`
* `SocketAddrV4::{new, ip, port, flowinfo, scope_id}`
* Common trait impls for socket addr structures
* `ToSocketAddrs`
* `ToSocketAddrs::Iter`
* `ToSocketAddrs::to_socket_addrs`
* `ToSocketAddrs for {SocketAddr*, (Ipv*Addr, u16), str, (str, u16)}`
* `Ipv4Addr`
* `Ipv4Addr::{new, octets, to_ipv6_compatible, to_ipv6_mapped}`
* `Ipv6Addr`
* `Ipv6Addr::{new, segments, to_ipv4}`
* `TcpStream`
* `TcpStream::connect`
* `TcpStream::{peer_addr, local_addr, shutdown, try_clone}`
* `{Read,Write} for {TcpStream, &TcpStream}`
* `TcpListener`
* `TcpListener::bind`
* `TcpListener::{local_addr, try_clone, accept, incoming}`
* `Incoming`
* `UdpSocket`
* `UdpSocket::bind`
* `UdpSocket::{recv_from, send_to, local_addr, try_clone}`
Unstable functionality:
* Extra methods on `Ipv{4,6}Addr` for various methods of inspecting the address
and determining qualities of it.
* Extra methods on `TcpStream` to configure various protocol options.
* Extra methods on `UdpSocket` to configure various protocol options.
Deprecated functionality:
* The `socket_addr` method has been renamed to `local_addr`
This commit is a breaking change due to the restructuring of the `SocketAddr`
type as well as the renaming of the `socket_addr` method. Migration should be
fairly straightforward, however, after accounting for the new level of
abstraction in `SocketAddr` (protocol distinction at the socket address level,
not the IP address).
[breaking-change]
2015-03-13 21:22:33 +00:00
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
2015-02-06 00:50:11 +00:00
|
|
|
Write,
|
2017-03-26 14:12:27 +00:00
|
|
|
/// Both the reading and the writing portions of the [`TcpStream`] should be shut down.
|
|
|
|
///
|
|
|
|
/// See [`Shutdown::Read`] and [`Shutdown::Write`] for more information.
|
2015-02-06 00:50:11 +00:00
|
|
|
///
|
2017-03-26 14:12:27 +00:00
|
|
|
/// [`TcpStream`]: ../../std/net/struct.TcpStream.html
|
|
|
|
/// [`Shutdown::Read`]: #variant.Read
|
|
|
|
/// [`Shutdown::Write`]: #variant.Write
|
std: Stabilize the `net` module
This commit performs a stabilization pass over the std::net module,
incorporating the changes from RFC 923. Specifically, the following actions were
taken:
Stable functionality:
* `net` (the name)
* `Shutdown`
* `Shutdown::{Read, Write, Both}`
* `lookup_host`
* `LookupHost`
* `SocketAddr`
* `SocketAddr::{V4, V6}`
* `SocketAddr::port`
* `SocketAddrV4`
* `SocketAddrV4::{new, ip, port}`
* `SocketAddrV6`
* `SocketAddrV4::{new, ip, port, flowinfo, scope_id}`
* Common trait impls for socket addr structures
* `ToSocketAddrs`
* `ToSocketAddrs::Iter`
* `ToSocketAddrs::to_socket_addrs`
* `ToSocketAddrs for {SocketAddr*, (Ipv*Addr, u16), str, (str, u16)}`
* `Ipv4Addr`
* `Ipv4Addr::{new, octets, to_ipv6_compatible, to_ipv6_mapped}`
* `Ipv6Addr`
* `Ipv6Addr::{new, segments, to_ipv4}`
* `TcpStream`
* `TcpStream::connect`
* `TcpStream::{peer_addr, local_addr, shutdown, try_clone}`
* `{Read,Write} for {TcpStream, &TcpStream}`
* `TcpListener`
* `TcpListener::bind`
* `TcpListener::{local_addr, try_clone, accept, incoming}`
* `Incoming`
* `UdpSocket`
* `UdpSocket::bind`
* `UdpSocket::{recv_from, send_to, local_addr, try_clone}`
Unstable functionality:
* Extra methods on `Ipv{4,6}Addr` for various methods of inspecting the address
and determining qualities of it.
* Extra methods on `TcpStream` to configure various protocol options.
* Extra methods on `UdpSocket` to configure various protocol options.
Deprecated functionality:
* The `socket_addr` method has been renamed to `local_addr`
This commit is a breaking change due to the restructuring of the `SocketAddr`
type as well as the renaming of the `socket_addr` method. Migration should be
fairly straightforward, however, after accounting for the new level of
abstraction in `SocketAddr` (protocol distinction at the socket address level,
not the IP address).
[breaking-change]
2015-03-13 21:22:33 +00:00
|
|
|
#[stable(feature = "rust1", since = "1.0.0")]
|
|
|
|
Both,
|
2015-02-06 00:50:11 +00:00
|
|
|
}
|
|
|
|
|
2015-04-17 22:32:42 +00:00
|
|
|
#[doc(hidden)]
|
|
|
|
trait NetInt {
|
|
|
|
fn from_be(i: Self) -> Self;
|
|
|
|
fn to_be(&self) -> Self;
|
|
|
|
}
|
|
|
|
macro_rules! doit {
|
|
|
|
($($t:ident)*) => ($(impl NetInt for $t {
|
|
|
|
fn from_be(i: Self) -> Self { <$t>::from_be(i) }
|
|
|
|
fn to_be(&self) -> Self { <$t>::to_be(*self) }
|
|
|
|
})*)
|
|
|
|
}
|
|
|
|
doit! { i8 i16 i32 i64 isize u8 u16 u32 u64 usize }
|
|
|
|
|
|
|
|
fn hton<I: NetInt>(i: I) -> I { i.to_be() }
|
|
|
|
fn ntoh<I: NetInt>(i: I) -> I { I::from_be(i) }
|
2015-02-06 00:50:11 +00:00
|
|
|
|
std: Stabilize the `net` module
This commit performs a stabilization pass over the std::net module,
incorporating the changes from RFC 923. Specifically, the following actions were
taken:
Stable functionality:
* `net` (the name)
* `Shutdown`
* `Shutdown::{Read, Write, Both}`
* `lookup_host`
* `LookupHost`
* `SocketAddr`
* `SocketAddr::{V4, V6}`
* `SocketAddr::port`
* `SocketAddrV4`
* `SocketAddrV4::{new, ip, port}`
* `SocketAddrV6`
* `SocketAddrV4::{new, ip, port, flowinfo, scope_id}`
* Common trait impls for socket addr structures
* `ToSocketAddrs`
* `ToSocketAddrs::Iter`
* `ToSocketAddrs::to_socket_addrs`
* `ToSocketAddrs for {SocketAddr*, (Ipv*Addr, u16), str, (str, u16)}`
* `Ipv4Addr`
* `Ipv4Addr::{new, octets, to_ipv6_compatible, to_ipv6_mapped}`
* `Ipv6Addr`
* `Ipv6Addr::{new, segments, to_ipv4}`
* `TcpStream`
* `TcpStream::connect`
* `TcpStream::{peer_addr, local_addr, shutdown, try_clone}`
* `{Read,Write} for {TcpStream, &TcpStream}`
* `TcpListener`
* `TcpListener::bind`
* `TcpListener::{local_addr, try_clone, accept, incoming}`
* `Incoming`
* `UdpSocket`
* `UdpSocket::bind`
* `UdpSocket::{recv_from, send_to, local_addr, try_clone}`
Unstable functionality:
* Extra methods on `Ipv{4,6}Addr` for various methods of inspecting the address
and determining qualities of it.
* Extra methods on `TcpStream` to configure various protocol options.
* Extra methods on `UdpSocket` to configure various protocol options.
Deprecated functionality:
* The `socket_addr` method has been renamed to `local_addr`
This commit is a breaking change due to the restructuring of the `SocketAddr`
type as well as the renaming of the `socket_addr` method. Migration should be
fairly straightforward, however, after accounting for the new level of
abstraction in `SocketAddr` (protocol distinction at the socket address level,
not the IP address).
[breaking-change]
2015-03-13 21:22:33 +00:00
|
|
|
fn each_addr<A: ToSocketAddrs, F, T>(addr: A, mut f: F) -> io::Result<T>
|
2015-02-06 00:50:11 +00:00
|
|
|
where F: FnMut(&SocketAddr) -> io::Result<T>
|
|
|
|
{
|
|
|
|
let mut last_err = None;
|
2016-03-23 03:01:37 +00:00
|
|
|
for addr in addr.to_socket_addrs()? {
|
2015-02-06 00:50:11 +00:00
|
|
|
match f(&addr) {
|
|
|
|
Ok(l) => return Ok(l),
|
|
|
|
Err(e) => last_err = Some(e),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Err(last_err.unwrap_or_else(|| {
|
|
|
|
Error::new(ErrorKind::InvalidInput,
|
2015-03-31 23:01:03 +00:00
|
|
|
"could not resolve to any addresses")
|
2015-02-06 00:50:11 +00:00
|
|
|
}))
|
|
|
|
}
|