I have an application in which i bound a socket to an outgoing interface from among a few using SO_BINDTODEVICE.
Now the problem is when i receive a response, i need to know which interface it came from. The ip address alone from which the response came is not enough, because same ip is bound to multiple interfaces.
I have used the code below provided in stackoverflow questions. But it fails giving segmentation faults in the second iteration of for loop (the first iteration went into continue part of loop).
Can some one help?
C++ DGRAM socket get the RECEIVER address
How to tell which interface the socket received the message from?