0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

Don't convert an ip to another ip; only convert a hostname to an ip

This commit is contained in:
Aaron 2009-01-21 15:32:58 -05:00
parent 6bb5ca74b8
commit 9a36738d0c
2 changed files with 6 additions and 2 deletions

View File

@ -22,9 +22,12 @@
namespace mongo {
static boost::mutex sock_mutex;
// .empty() if err
string hostbyname(const char *hostname) {
boostlock lk(sock_mutex);
struct in_addr temp;
if ( inet_aton( hostname, &temp ) )
return hostname;
struct hostent *h;
h = gethostbyname(hostname);
if ( h == 0 ) return "";

View File

@ -96,7 +96,8 @@ namespace mongo {
}
}
// .empty() if err
// If an ip address is passed in, just return that. If a hostname is passed
// in, look up its ip and return that. Returns "" on failure.
string hostbyname(const char *hostname);
struct SockAddr {