How to test udp batch packages in Java on one computer?

Can I execute UDP broadcast packets on my machine? I donโ€™t have a network, I just have a cheap box for Linux. I want the server to send a packet and two or more clients on the same computer as theirs. Is it possible? What is the IP address I use?


@gravyface gave me hope, but I tried: 1) send the server to 127.255.255.255:54321 and the clients that sent 0.0.0.0:54321. 2) sending the server to 127.255.255.255:54321 and clients listening on 127.0.0.1:54321. 3) sending a server to 127.255.255.255:54321 and clients listening on 127.255.255.255.255:54321. None of them work! : (

OBS: I use the REUSE_ADDR and SO_BROADCAST options.

+4
source share
2 answers

I can confirm that 127.255.255.255 works on Linux (Ubuntu) and it does not work on Mac (Snow Leopard). If you ever learn how to do this on a Mac, let me know. :)

+1
source

You can use virtual network adapters with different virtual addresses. For example, on Windows, you can use Microsoft Loopback or TUN / TAP on Linux.

Another solution would be to create an internal network with virtualization software such as VirtualBox, but this will require a small, faster machine. If you could afford (since this is a cheap box) on one virtual machine, you could enable 1-4 network adapters that would allow you to bind your different UDP clients separately on each of the virtual adapters of your virtual device.

0
source

All Articles