sockets - How to Broadcast to a shutdown system using java? -


we use socket.send(packet) function in java send "packet" given port. problem have send packet shutdown system using udp protocol. problem send() function first verifies whether host ip multicast or not. local area network of broadcast type. having problem using function. can please give me way ?

do know how send udp packets in java?

first of all, broadcasting must enabled in network.

then, servers must join agreed multicast address.

inetaddress address = inetaddress.getbyname( "230.0.0.1" ); multicastsocket socket = new multicastsocket( 12345 ); socket.joingroup( address ); 

when want activate system shutdown, send agreed message (for example, "die") multicast address.

datagrampacket packet = new datagrampacket( buf, buf.length ); socket.receive( packet ); string received = new string( packet.getdata(), 0, packet.getlength() ); 

the servers when accept message should initiate shutdown flow.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -