There is a server machine and the client is routed to the server using two routes.
Using netstat -r, I have both of the interface names. How do I create a Socket object using these names?
I know the Socket constructor has localAddr 3rd argument, but how to find it for a given interface name?
Note: netstat -r will print the interface names in the last column.
Socket(InetAddress serverAddr,
int port,
InetAddress localAddr,
int localPort)
throws IOException
Alternatively, you can define hostname for each interface (
/etc/hosts).This way you could construct the
InetAddressspeficying the hostname chosen.