title: Get local IP address for socket
body: <p>I'm looking to get the local IP address of the socket I just created. I need to be able to support a server with more than one NIC and communicate back to the requesting client what the direct IP address is to connect later on. I'm using for following code:</p>
  
  <pre><code>Socket rsock = null;
  rsock= new Socket(AddressFamily.InterNetworkV6, SocketType.Stream, ProtocolType.Tcp);
  rsock.SetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.IPv6Only, 0);
  rsock.Bind(new IPEndPoint(IPAddress.IPv6Any, port));
  rsock.Listen((int)SocketOptionName.MaxConnections);
  </code></pre>
  
  <p>After this point, .LocalEndPoint kicks out: [::]:PORT.</p>
  
  <p><strong>Background:</strong>
  The reason I need the IP address is that a secondary connection by another client will need to return to this specific server. These servers will likely be behind a load balancer for the initial server selection so the client cannot resolve the IP address based on the host name.</p>