there is few document on explain how IP_BOUND_IF works. I use the following code to specific interface to sending my data , where on a device has both wifi and vpn.
const char* device_name = "pdp_ip0";
int interfaceIndex = if_nametoindex(device_name);
int res = setsockopt(socketfd, IPPROTO_IP, IP_BOUND_IF, &interfaceIndex,
sizeof(interfaceIndex));
the res results 0 , but socket still send data via utun, witch is a vpn interface