title: casting sockaddr_storage as sockaddr_in for inet_ntop
body: <p>I am trying to cast a sockaddr_storage to a sockadd_in, so that i can print out the source ip address of a datagram packet,
  i do not seem to be able to get the cast correct, </p>
  
  <pre><code>struct sockaddr_storage  peer_addr;
  
  
  getnameinfo((struct sockaddr *) &amp;peer_add
                  peer_addrlen,
                  hostbuff, sizeof(hostbuff),
                  NULL, 0, NI_NAMEREQD);
  
  
  inet_ntop(AF_INET, (((struct sockaddr_in *)peer_addr).sin_addr), ipbuff, INET_ADDRSTRLEN);
  </code></pre>
  
  <p>when i try to cast the structure to a sockaddr_in, i either get 'cannot convert to pointer', or when i remove the dereferance i get 'conversion to non scaler type requested'.</p>
  
  <p>I have tried alot of combinations and simply don't understand where i am going wrong.</p>