]> git.donarmstrong.com Git - bamtools.git/blobdiff - src/api/internal/io/HostInfo_p.cpp
Updated file headers (filename, license, description, etc)
[bamtools.git] / src / api / internal / io / HostInfo_p.cpp
index 693b2f2f881c2f369bb9f99a0ae1ec9c8fff99de..80343f1cd9d1495486ebbe56fa9c9d32f6632073 100644 (file)
@@ -1,3 +1,12 @@
+// ***************************************************************************
+// HostInfo_p.cpp (c) 2011 Derek Barnett
+// Marth Lab, Department of Biology, Boston College
+// ---------------------------------------------------------------------------
+// Last modified: 10 November 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 <iostream> // debug
-
 // standard C++ includes
 #include <cstdlib>
 #include <cstring>
@@ -18,7 +25,7 @@ using namespace BamTools::Internal;
 using namespace std;
 
 // -------------------------
-// HostInfo basics
+// HostInfo implementation
 // -------------------------
 
 HostInfo::HostInfo(void)
@@ -66,9 +73,10 @@ 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) {
 
@@ -141,8 +149,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 +163,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 +171,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 +178,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);
                 }
             }