code: @Override
  	public boolean handleIncomingData()
  	{
  		lastRecvActivity = System.currentTimeMillis();
  		
  		while (inputBuffer.remaining() > 0)
  		{		
  			if (packetInputBuffer.size() == 0)
  			{
  				if (inputBuffer.remaining() >= 4) // packet_size = sizeof(int) = 4
  				{
  					int packetSize = inputBuffer.getInt();
  					
  					// Security check
  					int actualMaxPacketSize = Integer.MAX_VALUE;
  					if (maxPacketSize != -1)
  						actualMaxPacketSize = trustedConnection ? maxPacketSize : 1024;
  					
  					if (packetSize > actualMaxPacketSize)
  					{
  						log.error("#"+id+" packet is too large : "+packetSize+" (maxPacketSize="+actualMaxPacketSize+"), dropping client.");
  						return false;
  					}
  					
  					packetInputBuffer.setSize(packetSize);
  				}
  				else
  					return true; // Not enough data to proceed ...
  			}
  			else
  			{
  				// Append to current packet
  				int readAmount = Math.min(inputBuffer.remaining(), packetInputBuffer.size() - currentInputOffset);
  				packetInputBuffer.getFrom(inputBuffer, currentInputOffset, readAmount);
  				currentInputOffset += readAmount;
  				
  				// Packet is complete ?
  				if (currentInputOffset == packetInputBuffer.size())
  				{
  					AbstractPacket packet = unserializePacket(packetInputBuffer);
  					if (packet == null)
  						return false; // Invalid packet
  					packetInputBuffer.clear();
  					currentInputOffset = 0;
  					
  					if (traceEnabled)
  	                    log.trace("#"+id+" Received "+packet);
  					
  					if (listener != null)
  						trustedConnection = listener.packetReceived(packet);
  				}
  			}
  		}
  		
  		return true;
  	}
docs: /* (non-Javadoc)
  @see net.timewalker.ffmq4.transport.tcp.nio.NIOClientSocketHandler#handleIncomingData()