Linux allows to execute following code to bind a socket to some specific network interface. So, the data sent through this socket will always be channeled through the original interface.
setsockopt(socket, SOL_SOCKET, SO_BINDTODEVICE, name, strlen(name))
As I understand, this functionality is used in VPN clients. A socket gets connected to a remote server and bound to a network interface. This way, the traffic from VPN client itself won't be looped back into VPN client.
Is there OS X equivalent of doing this? Either
Binding a socket to some specific interface
Marking a socket in VPN client to not be looped back.
BTW. I found similar question, but I didn't understand the answer: Writing an OS X kernel extension to implement Linux's SO_BINDTODEVICE socket option
Update 1
I found out that some of VPN clients use TUN/TAP devices to prevent loopback problem. http://backreference.org/2010/03/26/tuntap-interface-tutorial/
However, I am not that that all OS X VPN uses that.