how to use cURL on specific interface

I am developing a code in c, which simply FTPs the files on FTP server by using curl utility, by following this example

now i have one simple thing to do, specify curl to use particular interface (IP) of the server for upload, as other interface of the server is associated with other socket connection.

is there any way to do it?


Seems like curl support --interface option

curl --interface eth0 

For anyone that comes here looking for the same answer, but for wlan0 or whatever the non-default interface is on Raspberry/RPi, you'll need to sudo or run as root.

In my case I was running eth0 and wlan0, but eth0 was my default NIC. Ping worked without sudo, curl didn't have verbose enough logging beyond saying the connection timed out and only worked without sudo on eth0. Traceroute finally led me to my answer when the error said "setsockopt SO_BINDTODEVICE: Operation not permitted"