title: How can I get IP information from a UDP socket (Windows C++)?
body: <p>I tried to find the IP address that my UDP socket is bound to (assuming I don't want to use another method to find the computer's IP address). How can this be done? The code below works for the PORT number, but always returns 0.0.0.0 for the address:</p>
  
  <pre><code>struct sockaddr_in sin;
  int addrlen = sizeof(sin);
  if(getsockname(clientSock, (struct sockaddr *)&amp;sin, &amp;addrlen) == 0 &amp;&amp;
      sin.sin_family == AF_INET &amp;&amp;
      addrlen == sizeof(sin)){
      printf("RETURNING ADDR: %s: len = %d\n", inet_ntoa(sin.sin_addr),
          strlen(inet_ntoa(sin.sin_addr)));
  }
  </code></pre>
  
  <p>The socket was bound using the following code:</p>
  
  <pre><code>sockaddr_in local;
  local.sin_family = AF_INET;
  local.sin_addr.s_addr = INADDR_ANY;//inet_addr("127.0.0.1");
  local.sin_port = 0; //assign given port
  result = bind(clientSock, (sockaddr*)&amp;local, sizeof(local));
  </code></pre>
  
  <p>Thank you for any and all help. I appreciate your time!</p>