June 2017
Beginner
1296 pages
69h 23m
English
... DatagramPacket(data,
45 data.length, InetAddress.getLocalHost(), 5000);
46
47 socket.send(sendPacket); // send packet
48 displayArea.append("Packet sent\n");
49 displayArea.setCaretPosition(
50 displayArea.getText().length());
51 }
52 catch (IOException ioException)
53 {
54 displayMessage(ioException + "\n");
55 ioException.printStackTrace();
56 }
57 }
58 }
59 );
60
61 add(enterField, BorderLayout.NORTH);
62
63 displayArea = new JTextArea();
64 add(new JScrollPane(displayArea), BorderLayout.CENTER);
65
66 setSize(400, 300); // set window size
67 setVisible(true); // show window
68
69 try // create DatagramSocket for sending and receiving packets
70 {
71 socket = new DatagramSocket();
72 }
73 catch (SocketException socketException)
74 {
75 socketException.printStackTrace(); ...Read now
Unlock full access