--- experimental/server/XMLReader/UDPReader.java 2000/11/21 09:15:06 1.6 +++ experimental/server/XMLReader/UDPReader.java 2000/11/21 10:27:24 1.9 @@ -19,6 +19,11 @@ public class UDPReader extends Thread{ this(4589, logger); } + public void receiveXML(String xml){ + UDPReaderThread t = new UDPReaderThread(); + t.run(xml); + } + public void run() { DatagramSocket socket = null; @@ -26,19 +31,17 @@ public class UDPReader extends Thread{ socket = new DatagramSocket(port); } catch (BindException e){ - System.out.println("Some other process is already listening on port "+port+"."); - System.out.println("Please specify another port number on the command line."); + logger.write(this.toString(), Logger.SYSMSG, "Could not start the UDPReader thread on port "+port+" as this port was already in use."); return; } catch (Exception e){ - System.out.println("An exception occured while creating the DatagramSocket."); + logger.write(this.toString(), Logger.SYSMSG, "Could not start the UDPReader thread on port "+port+"."); return; } - System.out.println("UDPReader ready and listening for UDP packets on port "+port); + logger.write(this.toString(), Logger.SYSMSG, "UDPReader thread ready and listening for UDP packets on port "+port); byte[] buf; - UDPReaderThread t = new UDPReaderThread(); boolean running = true; while (running){ @@ -47,11 +50,12 @@ public class UDPReader extends Thread{ // receive request DatagramPacket packet = new DatagramPacket(buf, buf.length); socket.receive(packet); + UDPReaderThread t = new UDPReaderThread(); t.run(packet); } catch (IOException e) { - System.out.println("An exception occured in the UDPReader!"); - e.printStackTrace(); + logger.write(this.toString(), Logger.SYSMSG, "The UDPReader thread has been shut down as an exception occured: "+e); + return; } } socket.close();