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:
- a
datagramsocket
. - some data in
byte[]
array. - a target address:port, expressed
inetsocketaddress
. - a
datagrampacket
, createdbyte[]
array , target address. datagramsocket.send()
.
you can't use 127. if want talk other hosts. addresses localhost-only.
Comments
Post a Comment