Package MyMenu; Import the java.net *. ; public class PracticeUsed { public static void main (String [] args) throws Exception { // . 1 udp service created by DategramSocket (); DatagramSocket DS = new new DatagramSocket (); // 2 determining the data packets encapsulated into byte [] = data "UDP GE LAI Le Men" .getBytes (); of DatagramPacket DP = new new of DatagramPacket (data, data.length, InetAddress.getByName ( "199.234.8.61"), 10000 ); // 3 existing service data packet sent by the socket, the send method ds.send (dp); // 4 Close resource // ---------------------------------- above sending end, the receiving end does not open } } class udpRece { } / * * transmitted through the UDP, the piece of data sent * ideas: * 1: establish service udpSocket * 2: providing data, the data encapsulated into packets 3 *: transmitting function and services through the Socket the data packet sent out * 4: Close the resource. * / / * Ideas: * 1 defined udpSocket service * 2 * * * * / * /
To be continued