gethostbyaddr returns 0
<p>I have a a variable that contains an IP address.  I am trying to do an nslookup on that by instead of the DNS name being returned I get 0.  I am in a Linux environment.  Destination IP comes from a vector (string dest_ip = vector[2]).</p>

<pre><code>#include &lt;stdio.h&gt;
#include &lt;iostream&gt;
#include &lt;string.h&gt;
#include &lt;arpa/inet.h&gt;
#include &lt;netdb.h&gt;
#include &lt;vector&gt;
#include &lt;algorithm&gt;
#include &lt;iterator&gt;
#include &lt;sstream&gt;

using namespace std;

void split(const std::string&amp; str, std::vector&lt;std::string&gt;&amp; v) {
    std::stringstream ss(str);
    ss &gt;&gt; std::noskipws;
    std::string field;
    char ws_delim;
    while(1) {
        if( ss &gt;&gt; field )
            v.push_back(field);
        else if (ss.eof())
            break;
        else
            v.push_back(std::string());
        ss.clear();
        ss &gt;&gt; ws_delim;
    }
}

int main()
{

  string input_line;

  while(cin){

  getline(cin, input_line);

   for(int i=0; input_line[i]; i++)
                      if(input_line[i] == ':') input_line[i] = ' ';
                     for(int i=0; input_line[i]; i++)
                      if(input_line[i] == '/') input_line[i] = ' ';

  std::vector&lt;std::string&gt; v;
  split(input_line, v);

  string dest_ip = v[4];

  struct hostent *he;
  int i,len,type;
  len = dest_ip.length();
  type=AF_INET;

  he = gethostbyaddr(dest_ip.c_str(),len,type);

  cout&lt;&lt;"Hostname: "&lt;&lt;he&lt;&lt;"\n";

  return 0;
}
</code></pre>

<p>Again, instead of receiving the host name I get 0.</p>
