title: getaddrinfo - Error: Success
body: <p>I am very confused.  </p>
  
  <p>I'm using <code>getaddrinfo</code> to get the address info for a given web host.  </p>
  
  <p>In this case, I've been using <code>www.cmu.edu</code>.  </p>
  
  <p>My code was working for a little while, but then it stopped.  </p>
  
  <p>The odd part is the fact that I'm clearly coming up with an error, but when the error code is printed out, it says "success."</p>
  
  <p>Here are the relevant bits of code:</p>
  
  <pre><code>struct addrinfo *res = NULL;
  struct addrinfo hint;
  
  memset(&amp;hint, 0, sizeof(hint));
  hint.ai_family = AF_UNSPEC;
  hint.ai_socktype = SOCK_DGRAM;
  hint.ai_flags = 0;
  hint.ai_protocol = 17;
  
  if (getaddrinfo(host, portNo, &amp;hint, &amp;res))
  {
    perror("getaddrinfo");
    return 0;
  }
  </code></pre>
  
  <p>Host and portNo are strings containing the host (in this case, "<code>www.cmu.edu</code>") and the port (in this case, "80").  </p>
  
  <p>They definitely contain the right thing, no extra spaces or anything like that.</p>
  
  <p>Edit: Thanks everyone!  I at least have an appropriate error message now, even though I still have no idea why things stopped working.  The error message is:  </p>
  
  <pre><code>Servname not supported for ai_socktype
  </code></pre>
  
  <p>I've been looking at possible causes for this error and I haven't found anything.  As I said, this code was working earlier and stopped without me changing anything.  I deduced that it may be the port number I was using, but I've changed it several times and nothing changed.  </p>
  
  <p>Any insight?  I'm not attached to the port number or anything except the host.  I'm just trying to get it working.</p>