ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/experimental/server/XMLReader/UDPReaderThread.java
Revision: 1.6
Committed: Tue Nov 21 09:26:09 2000 UTC (24 years ago) by pjm2
Branch: MAIN
Changes since 1.5: +1 -1 lines
Log Message:
Modified the port number used by XMLSender2.

Altered UDPReaderThread such that a 'proper' thread is run.

File Contents

# Content
1 import java.io.*;
2 import java.net.*;
3 import java.util.*;
4
5 public class UDPReaderThread extends Thread{
6
7 public UDPReaderThread(){
8 // no-args constructor.
9 }
10
11 public void run(DatagramPacket packet){
12 rawPacket = packet.getData();
13 start();
14 }
15
16 public void run(){
17
18 // Get a string without any null characters in it.
19 String xml = new String(rawPacket);
20 xml = xml.substring(0, xml.indexOf(0));
21
22 // USe my XMLPacketMaker to make an XMLPacket object.
23 XMLPacketMaker xmlPacketMaker = new XMLPacketMaker(xml);
24 XMLPacket packet = xmlPacketMaker.createXMLPacket();
25
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 // .... but what? ;-)
34
35 }
36
37 byte[] rawPacket;
38 }