1 |
pjm2 |
1.1 |
import java.io.*; |
2 |
|
|
import java.net.*; |
3 |
|
|
import java.util.*; |
4 |
|
|
|
5 |
|
|
public class XMLReader { |
6 |
|
|
|
7 |
|
|
public static void main(String[] args) throws IOException { |
8 |
|
|
|
9 |
|
|
DatagramSocket socket = new DatagramSocket(4589); |
10 |
|
|
|
11 |
|
|
try { |
12 |
|
|
byte[] buf = new byte[1024]; |
13 |
|
|
// receive request |
14 |
|
|
DatagramPacket packet = new DatagramPacket(buf, buf.length); |
15 |
|
|
socket.receive(packet); |
16 |
|
|
String dataIn = new String(packet.getData()); |
17 |
|
|
System.out.println("Received: " + dataIn); |
18 |
|
|
} |
19 |
|
|
catch (IOException e) { |
20 |
|
|
System.out.println("An exception occured!"); |
21 |
|
|
e.printStackTrace(); |
22 |
|
|
} |
23 |
|
|
socket.close(); |
24 |
|
|
} |
25 |
|
|
} |