about summary refs log tree commit diff
path: root/src/libstd/io
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstd/io')
-rw-r--r--src/libstd/io/net/addrinfo.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/libstd/io/net/addrinfo.rs b/src/libstd/io/net/addrinfo.rs
index 69ba64d856e..e8fbb121181 100644
--- a/src/libstd/io/net/addrinfo.rs
+++ b/src/libstd/io/net/addrinfo.rs
@@ -10,8 +10,8 @@
 
 //! Synchronous DNS Resolution
 //!
-//! Contains the functionality to perform DNS resolution in a style related to
-//! `getaddrinfo()`
+//! Contains the functionality to perform DNS resolution or reverse lookup,
+//! in a style related to `getaddrinfo()` and `getnameinfo()`, respectively.
 
 #![allow(missing_docs)]
 
@@ -24,6 +24,7 @@ use io::{IoResult};
 use io::net::ip::{SocketAddr, IpAddr};
 use option::Option;
 use option::Option::{Some, None};
+use string::String;
 use sys;
 use vec::Vec;
 
@@ -83,6 +84,12 @@ pub fn get_host_addresses(host: &str) -> IoResult<Vec<IpAddr>> {
     lookup(Some(host), None, None).map(|a| a.into_iter().map(|i| i.address.ip).collect())
 }
 
+/// Reverse name resolution. Given an address, returns the corresponding
+/// hostname.
+pub fn get_address_name(addr: IpAddr) -> IoResult<String> {
+    sys::addrinfo::get_address_name(addr)
+}
+
 /// Full-fledged resolution. This function will perform a synchronous call to
 /// getaddrinfo, controlled by the parameters
 ///