ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/experimental/server/XMLReader/UDPReaderThread.java
Revision: 1.5
Committed: Fri Nov 17 20:44:31 2000 UTC (24 years ago) by pjm2
Branch: MAIN
Changes since 1.4: +8 -8 lines
Log Message:
UDPReader and UDPReaderThread have been altered to prevent
a serious problem whereby the system ran out of free memory
after a certain amount of UDP packets had been received.

Testing with XMLSender2 has revealed that this problem has
been solved.  There is now little chance of the UDPReader
rejecting packets as it queues each arrival straight to the
UDPReaderThread, thus making "event storms" managable.  In
fact, the queuing nature may even assist in quenching such
problems.

File Contents

# User Rev Content
1 pjm2 1.1 import java.io.*;
2     import java.net.*;
3     import java.util.*;
4    
5     public class UDPReaderThread extends Thread{
6    
7 pjm2 1.5 public UDPReaderThread(){
8     // no-args constructor.
9     }
10    
11     public void run(DatagramPacket packet){
12     rawPacket = packet.getData();
13     run();
14 pjm2 1.1 }
15    
16     public void run(){
17 pjm2 1.2
18 pjm2 1.4 // Get a string without any null characters in it.
19 pjm2 1.3 String xml = new String(rawPacket);
20     xml = xml.substring(0, xml.indexOf(0));
21    
22 pjm2 1.4 // USe my XMLPacketMaker to make an XMLPacket object.
23 pjm2 1.1 XMLPacketMaker xmlPacketMaker = new XMLPacketMaker(xml);
24     XMLPacket packet = xmlPacketMaker.createXMLPacket();
25 pjm2 1.2
26     if (packet == null){
27     System.out.println("UDPReaderThread - A null XMLPacket was returned, I think I'll ignore it!");
28     return;
29     }
30     System.out.println("UDPReaderThread - An XML Packet was read sucessfully: -");
31     packet.printAll();
32     // Now do something with this XMLPacket!!!
33 pjm2 1.4 // .... but what? ;-)
34 pjm2 1.5
35 pjm2 1.1 }
36    
37 pjm2 1.3 byte[] rawPacket;
38 pjm2 1.1 }