public byte[] receive() throws NetworkException {
  try {
    packet.setLength(DatagramConnection.DEFAULT_DATAGRAM_SIZE);
    connection.receive(packet);
    int packetLength=packet.getLength();
    byte[] data=new byte[packetLength];
    System.arraycopy(packet.getData(),0,data,0,packetLength);
    return data;
  }
 catch (  IOException e) {
    throw new NetworkException("Failed to receive datagram packet!",e);
  }
}

public byte [ ] receive ( ) throws NetworkException { try { packet . setLength ( DatagramConnection . DEFAULT_DATAGRAM_SIZE ) ; connection . receive ( packet ) ; int packetLength = packet . getLength ( ) ; byte [ ] data = new byte [ packetLength ] ; System . arraycopy ( packet . getData ( ) , 0 , data , 0 , packetLength ) ; return data ; } catch ( IOException e ) { throw new NetworkException ( "Failed to receive datagram packet!" , e ) ; } }
receive data with a specific buffer size
