@Override
	public void read() throws IOException
	{
		if (isNotReady()) 
		{
			return;
		}
		
		long startTime = System.nanoTime();
		
		inbound.clear();
		
		packetsRead = 0;
		
		int read = onRead( buffer );
		
		if (read == -1)
		{
			close();
		}
		else
		{
			buffer.flip();
			
			while (!closed && readBuffer(buffer))
			{
				packetsRead++;
			}
			
			if (!closed && packetsRead > 0)
			{
			    compact( buffer );
			}
		}
		
		durationRead = System.nanoTime() - startTime;
	}