title: Get wrong IP address when using bind() in C
body: <p>I'm using socket programing APIs in C. In a TCP client-side program, I use <code>bind()</code>, and then use <code>getsockname()</code> (before calling <code>connect()</code>) to get the local machine's IP address and port number. However, I can only get the correct port number, while getting a wrong IP address (a zero). </p>
  
  <p>So I'm asking if there is any way to correctly get a correct IP address for local machine (before calling <code>connect()</code>)?</p>