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