}
log.info("Started successfully " + getType() + " UDP driver on '" + socketUrl.getUrl() + "'");
byte packetBuffer[] = new byte[MAX_PACKET_SIZE];
DatagramPacket packet = new DatagramPacket(packetBuffer, packetBuffer.length);
MsgInfo receiver = null;
listenerReadyUDP = true;
while (runningUDP) {
try {
socketUDP.receive(packet);
}
catch (IOException e) {
if (e.toString().indexOf("closed") == -1) {
log.severe("Error receiving packet from '" + socketUrl.getUrl() + "' : " + e.toString());
}
else {
if (log.isLoggable(Level.FINE)) log.fine("UDP datagram socket shutdown '" + socketUrl.getUrl() + "' : " + e.toString());
}
return;
}
if (log.isLoggable(Level.FINE))
log.fine("UDP packet arrived, size=" + packet.getLength() + " bytes");
if (!runningUDP) {
log.info("Closing server '" + socketUrl.getUrl() + "'");
return;
}
int actualSize = packet.getLength();
if (packet.getLength() > MAX_PACKET_SIZE) {
log.warning("Packet has been truncated, size=" + packet.getLength() + ", MAX_PACKET_SIZE=" + MAX_PACKET_SIZE);
actualSize = MAX_PACKET_SIZE;
}
InputStream iStream = new ByteArrayInputStream(packet.getData(), 0, actualSize);
try {
receiver = MsgInfo.parse(glob, null, iStream, null/*getMsgInfoParserClassName()*/, getPluginConfig())[0];
}
catch (Throwable e) {
log.severe("Error parsing data from UDP packet: " + e);