title: Why does getaddrinfo return a port number of 20480 for HTTP?
body: <p>Here is my code.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;inttypes.h&gt;
  #include &lt;sys/types.h&gt;
  #include &lt;sys/socket.h&gt;
  #include &lt;netdb.h&gt;
  
  int main()
  {
      struct addrinfo *ai, *p;
  
      if (getaddrinfo("localhost", "http", NULL, &amp;ai) != 0) {
          printf("error\n");
          return EXIT_FAILURE;
      }
  
      for (p = ai; p != NULL; p = p-&gt;ai_next)
      {
          if (p-&gt;ai_family == AF_INET) {
              struct sockaddr_in *addr = (struct sockaddr_in *) p-&gt;ai_addr;
              printf("IPv4 port: %d\n", addr-&gt;sin_port);
          } else if (p-&gt;ai_family == AF_INET6) {
              struct sockaddr_in6 *addr = (struct sockaddr_in6 *) p-&gt;ai_addr;
              printf("IPv6 port: %d\n", addr-&gt;sin6_port);
          }
      }
  
      return 0;
  }
  </code></pre>
  
  <p>Here is the output.</p>
  
  <pre><code>$ gcc -std=c99 -D_POSIX_SOURCE -Wall -Wextra -pedantic foo.c
  $ ./a.out 
  IPv6 port: 20480
  IPv6 port: 20480
  IPv4 port: 20480
  IPv4 port: 20480
  </code></pre>
  
  <p>I was expecting the port number to be 80. Why do I see 20480 in the output then?</p>