title: getaddrinfo failing with error : Servname not supported for ai_socktype in C++
body: <p>This, I observed, because of the port. port is C++ string. When I hard code the port number say "4091" I dont see this issue. Any suggestions?</p>
  
  <pre><code>int sockfd;
  struct addrinfo hints, *servinfo, *p;
  int rv;
  
  memset(&amp;hints, 0, sizeof hints);
  hints.ai_family = AF_UNSPEC; 
  hints.ai_socktype = SOCK_DGRAM;
  hints.ai_flags = AI_PASSIVE; 
  
  cout &lt;&lt; "port: " &lt;&lt; port &lt;&lt; endl;
  
  const char * por = port.c_str();
  
  if ((rv = getaddrinfo(NULL, por, &amp;hints, &amp;servinfo)) != 0) {
      fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(rv));
  }
  </code></pre>