X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=src%2Fapi%2Finternal%2Fio%2FHostInfo_p.cpp;h=40b1047214233b37c59a72cf6625ca83fb36318e;hb=61f4f02a6f27510e96de59dda110f6e5de3236ba;hp=693b2f2f881c2f369bb9f99a0ae1ec9c8fff99de;hpb=8e8ed0f0d520fa4d240ab98bd7cc0b0933777fdb;p=bamtools.git diff --git a/src/api/internal/io/HostInfo_p.cpp b/src/api/internal/io/HostInfo_p.cpp index 693b2f2..40b1047 100644 --- a/src/api/internal/io/HostInfo_p.cpp +++ b/src/api/internal/io/HostInfo_p.cpp @@ -1,3 +1,12 @@ +// *************************************************************************** +// HostInfo_p.cpp (c) 2011 Derek Barnett +// Marth Lab, Department of Biology, Boston College +// --------------------------------------------------------------------------- +// Last modified: 8 December 2011 (DB) +// --------------------------------------------------------------------------- +// Provides DNS lookup functionality for hostname & its discovered addresses +// *************************************************************************** + #include "api/internal/io/HostInfo_p.h" using namespace BamTools; using namespace BamTools::Internal; @@ -9,8 +18,6 @@ using namespace BamTools::Internal; # include "api/internal/io/NetUnix_p.h" #endif -#include // debug - // standard C++ includes #include #include @@ -18,7 +25,7 @@ using namespace BamTools::Internal; using namespace std; // ------------------------- -// HostInfo basics +// HostInfo implementation // ------------------------- HostInfo::HostInfo(void) @@ -66,13 +73,15 @@ void HostInfo::SetHostName(const string& name) { m_hostName = name; } -// ------------------------------ +// --------------------------------- // HostInfo::Lookup(host, port) -// ------------------------------ +// - the real "heavy-lifter" here +// --------------------------------- HostInfo HostInfo::Lookup(const string& hostname, const string& port) { HostInfo result; + result.SetHostName(hostname); set uniqueAddresses; #ifdef _WIN32 @@ -141,8 +150,6 @@ HostInfo HostInfo::Lookup(const string& hostname, const string& port) { // do 'normal' lookup else { - cout << "HostInfo::Lookup() - looking up addresses for domain name: " << hostname << endl; - // setup address lookup 'hints' addrinfo hints; memset(&hints, 0, sizeof(hints)); @@ -157,8 +164,6 @@ HostInfo HostInfo::Lookup(const string& hostname, const string& port) { // if everything OK if ( status == 0 ) { - cout << "HostInfo::Lookup() - found addresses" << endl; - // iterate over all IP addresses found addrinfo* p = res; for ( ; p != NULL; p = p->ai_next ) { @@ -167,7 +172,6 @@ HostInfo HostInfo::Lookup(const string& hostname, const string& port) { if ( p->ai_family == AF_INET ) { sockaddr_in* ipv4 = (sockaddr_in*)p->ai_addr; HostAddress a( ntohl(ipv4->sin_addr.s_addr) ); - cout << "\t" << a.GetIPString() << endl; uniqueAddresses.insert(a); } @@ -175,7 +179,6 @@ HostInfo HostInfo::Lookup(const string& hostname, const string& port) { else if ( p->ai_family == AF_INET6 ) { sockaddr_in6* ipv6 = (sockaddr_in6*)p->ai_addr; HostAddress a(ipv6->sin6_addr.s6_addr); - cout << "\t" << a.GetIPString() << endl; uniqueAddresses.insert(a); } }