Code example for DatagramPacket

Methods: getAddress, getData, getLength, getPort

0
	} 
 
 
	@Override 
	public void run() { 
		String msg = new String(packet.getData(), 0, packet.getLength());
 
		//msg decode 
		int tcpPort = 0;
		int minCons = 0;
		int maxCons = 0;
		String[] msgParts = msg.split(" ");
		try { 
			tcpPort = Integer.parseInt(msgParts[0]);
			minCons = Integer.parseInt(msgParts[1]);
			maxCons = Integer.parseInt(msgParts[2]);
		} catch (NumberFormatException exc) {
			LOG.warn("parsing failed");
		} 
 
		//update time if engine already in hashtable, add new engine with time otherwise 
		InetAddress ip = packet.getAddress();
		int udp = packet.getPort();
		EngineIdentifier currEngine = new EngineIdentifier(ip, tcpPort);
		if(engines.containsKey(currEngine)) {
			if(engines.get(currEngine).isOffline()) {
				engines.get(currEngine).setActive();
			}