Question

I have 2 Ethernet interfaces configured in my Linux Machine. Lets say Interface A and Interface B.

I am writing a tcp client socket program and need to send the packets on the defined interface.

For example.

./client -intf interface A/B

if it the input is interface A, then the client has to send packets only via interface A and vice versa.

Could anyone provides some hint on how to implement this?.

Thanks in advance!!!

Was it helpful?

OTHER TIPS

You can use bind() before you call connect() to bind your client socket to a particular IP address. You can use getifaddrs() to list the interfaces and their associated IP addresses.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top