private boolean isPacketLongEnough ( DatagramPacket packet , int expectedLength , String name ) { final int length = packet . getLength ( ) ; if ( length < expectedLength ) { logger . warn ( "Ignoring too-short " + name + " packet; expecting " + expectedLength + " bytes and got " + length + "." ) ; return false ; } if ( length > expectedLength ) { logger . warn ( "Processing too-long " + name + " packet; expecting " + expectedLength + " bytes and got " + length + "." ) ; } return true ; }
Helper method to check that we got the right size packet .