summary refs log tree commit diff
path: root/src/libstd/io
diff options
context:
space:
mode:
authorMurarth <murarth@gmail.com>2014-12-28 15:44:25 -0700
committerMurarth <murarth@gmail.com>2014-12-28 15:45:43 -0700
commite6c8b8f480712d346c9b92f06217b4c56c15610c (patch)
tree784645a066c92de80a6bdf3f7e8c5ab1adbdd6a2 /src/libstd/io
parent3e6b29f8ad1ddfcb134d743a66ee5f467e16c350 (diff)
downloadrust-e6c8b8f480712d346c9b92f06217b4c56c15610c.tar.gz
rust-e6c8b8f480712d346c9b92f06217b4c56c15610c.zip
Added `get_address_name`, an interface to `getnameinfo`
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
 ///