title: Reasoning behind C sockets sockaddr and sockaddr_storage
body: <p>I'm looking at functions such as <code>connect()</code> and <code>bind()</code> in C sockets and notice that they take a pointer to a <code>sockaddr</code> struct. I've been reading and to make your application AF-Independent, it is useful to use the <code>sockaddr_storage</code> struct pointer and cast it to a <code>sockaddr</code> pointer because of all the extra space it has for larger addresses.</p>
  
  <p>What I am wondering is how functions like <code>connect()</code> and <code>bind()</code> that ask for a <code>sockaddr</code> pointer go about accessing the data from a pointer that points at a larger structure than the one it is expecting. Sure, you pass it the size of the structure you are providing it, but what is the actual syntax that the functions use to get the IP Address off the pointers to larger structures that you have cast to <code>struct *sockaddr</code>?</p>
  
  <p>It's probably because I come from OOP languages, but it seems like kind of a hack and a bit messy.</p>