title: bind socket to network interface
body: <p>How can I bind a socket to a particular network interface? I tried using <code>setsockopt</code> on server side, but the clients can still access the service through both eth0 and lo interfaces.</p>
  
  <p>I can achieve this by setting the particular IP address using  <code>serv_addr.sin_addr.s_addr</code>.</p>
  
  <p>But I suspect that we can bind to an interface using only <code>setsockopt</code> (without mentioning the IP address).</p>