networking - How to send datagram to other machines from one ip address to another ip address in java -


i want send messages other machines using udp protocol in java. , knew ip address , broadcast address should advertise on. ip address 127.0.0.1, , other address 127.0.0.200. want broadcast message machines addresses 127.0.0.1 127.0.0.200. how implement in java?

and range of ip address may 127.0.0.1 127.1.4.80.

i beginner , know should use inetaddress type express ip address. don't know how iterate inetaddress objects.

could me?

thanks lot!!

you need:

  1. a datagramsocket.
  2. some data in byte[] array.
  3. a target address:port, expressed inetsocketaddress.
  4. a datagrampacket, created byte[] array , target address.
  5. datagramsocket.send().

you can't use 127. if want talk other hosts. addresses localhost-only.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -