Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java udp send from specific IP address

I have a server with many IP addresses, and a UDP socket bound to 0.0.0.0 so I can receive UDP from any of them. How can I specify the source IP address to use in the UDP packets I am sending? My current implementation is using NIO so maybe using the DatagramChannel to perform the sending is the problem.

like image 933
klaxxon Avatar asked Apr 15 '26 06:04

klaxxon


1 Answers

I gave up on a clean solution and just use a bound DatagramSocket per IP address on server that can be used to send UDP with the specific source IP for the outbound packets.

like image 156
klaxxon Avatar answered Apr 16 '26 19:04

klaxxon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!