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