Here's simple case when binding to all ip interfaces and specific udp port:
int bindPort = 5555; // example, udp port number
DatagramSocket socket = new DatagramSocket(bindPort);
byte[] receiveData = new byte[1500];
DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length);
...
socket.receive(receivePacket);
How do I know on which ip interface I received packet ?
I can see there is getSocketAddress():
Gets the SocketAddress (usually IP address + port number) of the remote host that this packet is being sent to or is coming from.
but that returns remote ip+port. I would like to know local ip (local port is 5555 in this example).
Is it possible with std. Java libraries ?