title: How to get the port number from struct addrinfo in unix c
body: <p>I need to send some data to a remote server via UDP in a particular port and get receive a response from it. However, it is blocking and I do not get any response. I need to check if the addrinfo value that I get from the <code>getaddrinfo(SERVER_NAME, port, &amp;hints, &amp;servinfo)</code> is correct or not.</p>
  
  <p>How do I get the port number from this data structure?</p>
  
  <p>I know <code>inet_ntop(p-&gt;ai_family, get_in_addr((struct sockaddr *)p-&gt;ai_addr), s, sizeof s)</code> gives me server IP address. (I am using the method in Beej's guide.)</p>