title: service to port number like getaddrinfo
body: <p>In C you can use a service name to get the port number when using getaddrinfo, like this:</p>
  
  <pre><code>getaddrinfo("stackoverflow.com", "http", &amp;hints, &amp;results);
  </code></pre>
  
  <p>This will assign 80 (big endian) to the first two bytes (uint16_t) of results->ai_addr.</p>
  
  <p>Is there some easy way to get the port number from ?only? giving the service name? I need this for the server side, where I want to allow the user to specify either port number or service name for the port to bind and listen to.</p>