I have a DatagramSocket
via which UDP packet are sent from client to server and vice versa. I have to include IP source address in reply packet to client. Is there a way to obtain such as IP address using Java?
I add some clarification I have no control in UDP client, this is a thirt party client. I can only have control in UDP server. So I cannot use DatagramPacket.getAddress() in client source code but only in server source code. I know that is not necessary to include IP Address source in the datagram packet since the source IP address is always available to the receiver (from UDP header I think) but in my case I have sort of handshake between client and server so I have to include server Address in UDP payload data.
CLIENT 192.168.x.x send UDP packet to SERVER 192.168.255.255:8010 in reply to this server should send back to client a replay datagramPacket in wich I should Add the server address (es 192.168.y.y)