| 7 |
|
// This class contains the main method to be run by |
| 8 |
|
// the filter children. It harvests UDP traffic. |
| 9 |
|
// |
| 10 |
– |
// |
| 10 |
|
public class UDPReader extends Thread{ |
| 11 |
|
|
| 12 |
|
// It is normal to use this constructor in preference |
| 28 |
|
socket = new DatagramSocket(port); |
| 29 |
|
} |
| 30 |
|
catch (BindException e){ |
| 31 |
< |
logger.write(this.toString(), Logger.SYSMSG, "Could not start the UDPReader thread on port "+port+" as this port was already in use."); |
| 31 |
> |
logger.write(this.toString(), Logger.FATAL, "Could not start the UDPReader thread on port "+port+" as this port was already in use."); |
| 32 |
|
return; |
| 33 |
|
} |
| 34 |
|
catch (Exception e){ |
| 35 |
< |
logger.write(this.toString(), Logger.SYSMSG, "Could not start the UDPReader thread on port "+port+"."); |
| 35 |
> |
logger.write(this.toString(), Logger.FATAL, "Could not start the UDPReader thread on port "+port+"."); |
| 36 |
|
return; |
| 37 |
|
} |
| 38 |
|
|
| 43 |
|
boolean running = true; |
| 44 |
|
while (running){ |
| 45 |
|
try { |
| 46 |
+ |
|
| 47 |
+ |
// receive request and pass on to the FilterThread. |
| 48 |
|
buf = new byte[packetSizeLimit]; |
| 48 |
– |
// receive request |
| 49 |
|
DatagramPacket packet = new DatagramPacket(buf, buf.length); |
| 50 |
|
socket.receive(packet); |
| 51 |
< |
FilterThread t = new FilterThread(parent); |
| 52 |
< |
t.run(packet); |
| 51 |
> |
FilterThread t = new FilterThread(parent, packet); |
| 52 |
> |
t.start(); |
| 53 |
> |
|
| 54 |
|
} |
| 55 |
|
catch (IOException e) { |
| 56 |
< |
logger.write(this.toString(), Logger.SYSMSG, "The UDPReader thread has been shut down as an exception occured: "+e); |
| 56 |
> |
logger.write(this.toString(), Logger.WARNING, "This UDPReader thread has been shut down as an exception occured: "+e); |
| 57 |
|
return; |
| 58 |
|
} |
| 59 |
|
} |