ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/experimental/server/XMLReader/UDPReader.java
Revision: 1.1
Committed: Fri Nov 17 11:23:19 2000 UTC (24 years ago) by pjm2
Branch: MAIN
Log Message:
The UDPReader class contains a main method for running on a machine to
accept the UDP XML data coming in.  Once it receives something, it passes
it on to a separate UDPReaderThread class to try and prevent the loss of
packets.

File Contents

# Content
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 }