title: Determine address family of an unbound socket
body: <p>When I try to bind my socket I need to specify the address family in the addrinfo/sockaddr-structure I pass in to the call to bind(), or one will get an winsock error 10047 (Address family not supported by protocol family.)</p>
  
  <p>What if I created a socket elswhere not knowing its address family...
  How could I get the address family for that socket, so i can bind it?</p>
  
  <p>getsockname only works for bound sockets :/...</p>
  
  <p>I don´t want to force the caller of my function to pass the address family to my functions, especially if she/he/it uses AF_UNSPEC/PF_UNSPEC when creating her/his socket</p>
  
  <p>(e.g. <code>SOCKET sock = socket(AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP);</code> )</p>