{
boolean packetReceived=false;
SocketChannel channel = (SocketChannel) key.channel();
int count;
buffer.clear(); // make buffer empty
ObjectReader reader = (ObjectReader)key.attachment();
// loop while data available, channel is non-blocking
while ((count = channel.read (buffer)) > 0) {
buffer.flip(); // make buffer readable
reader.append(buffer.array(),0,count);
buffer.clear(); // make buffer empty
}
//check to see if any data is available
int pkgcnt = reader.execute();
if (log.isTraceEnabled()) {
log.trace("sending " + pkgcnt + " ack packages to " + channel.socket().getLocalPort() );
}
if (sendAck) {