bind socket to network interface

view story

http://stackoverflow.com – How can we bind an socket to particular network interface? i tried using setsockopt on server side. still client can access through both eth0 and lo interfaces. I can achieve this by setting the particular ip address using serv_addr.sin_addr.s_addr. But my doubt is can we use only setsockopt to bind to interface without mentioning the ipaddress. (HowTos)