19 |
|
this(4589, logger); |
20 |
|
} |
21 |
|
|
22 |
+ |
public void receiveXML(String xml){ |
23 |
+ |
UDPReaderThread t = new UDPReaderThread(); |
24 |
+ |
t.run(xml); |
25 |
+ |
} |
26 |
+ |
|
27 |
|
public void run() { |
28 |
|
|
29 |
|
DatagramSocket socket = null; |
31 |
|
socket = new DatagramSocket(port); |
32 |
|
} |
33 |
|
catch (BindException e){ |
34 |
< |
System.out.println("Some other process is already listening on port "+port+"."); |
30 |
< |
System.out.println("Please specify another port number on the command line."); |
34 |
> |
logger.write(this.toString(), Logger.SYSMSG, "Could not start the UDPReader thread on port "+port+" as this port was already in use."); |
35 |
|
return; |
36 |
|
} |
37 |
|
catch (Exception e){ |
38 |
< |
System.out.println("An exception occured while creating the DatagramSocket."); |
38 |
> |
logger.write(this.toString(), Logger.SYSMSG, "Could not start the UDPReader thread on port "+port+"."); |
39 |
|
return; |
40 |
|
} |
41 |
|
|
42 |
< |
System.out.println("UDPReader ready and listening for UDP packets on port "+port); |
42 |
> |
logger.write(this.toString(), Logger.SYSMSG, "UDPReader thread ready and listening for UDP packets on port "+port); |
43 |
|
|
44 |
|
byte[] buf; |
41 |
– |
UDPReaderThread t = new UDPReaderThread(); |
45 |
|
|
46 |
|
boolean running = true; |
47 |
|
while (running){ |
50 |
|
// receive request |
51 |
|
DatagramPacket packet = new DatagramPacket(buf, buf.length); |
52 |
|
socket.receive(packet); |
53 |
+ |
UDPReaderThread t = new UDPReaderThread(); |
54 |
|
t.run(packet); |
55 |
|
} |
56 |
|
catch (IOException e) { |
57 |
< |
System.out.println("An exception occured in the UDPReader!"); |
58 |
< |
e.printStackTrace(); |
57 |
> |
logger.write(this.toString(), Logger.SYSMSG, "The UDPReader thread has been shut down as an exception occured: "+e); |
58 |
> |
return; |
59 |
|
} |
60 |
|
} |
61 |
|
socket.close(); |