Symbian
Symbian OS Library

FAQ-0748 Why does my application have problems receiving Datagrams when ported to the target device?

[Index][spacer] [Previous] [Next]



 

Classification: Java Category: JavaPhone
Created: 11/13/2001 Modified: 12/11/2001
Number: FAQ-0748
Platform: Symbian OS v6.0, Symbian OS v6.1, Symbian OS v7.0

Question:
Why does my application have problems receiving Datagrams when ported to the target device, although it runs correctly on the emulator?

Answer:
The maximum size of Datagrams is 8kB and 48 kB for WDP over SMS and UDP Datagrams respectively. Using the emulator, with the large memory resources available on a PC platform, this causes no particular problem. However, when ported to the target hardware, with its highly restricted resources, problems may occur receiving multiple successive Datagrams whose buffer sizes have been set to the maximum length. Developers should bear this in mind when designing and developing their applications and where possible limit the maximum size of Datagrams to be sent and received. The size of the byte array should then be explicitly set to an appropriate value. So instead of
    DatagramService receiveService = DatagramService.getServerService(address);
    byte[] buffer = new byte[receiveService.getMaximumLength()];
    Datagram reply = new Datagram(buffer);

    you should explicitly set the size of the byte array to the maximum that your application requires. For instance

    public static final int MAX_SIZE = 100;

    ...

    byte[] buffer = new byte[MAX_SIZE];