BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 10-30-2008, 09:07 AM   #1 (permalink)
New Member
 
Join Date: Jul 2008
Model: 8320
PIN: N/A
Carrier: MTS
Posts: 5
Post Thanks: 0
Thanked 0 Times in 0 Posts
Question Battery Consumption and networking

Please Login to Remove!

Please let me know if there are any issues with keeping an instant connection to a server and how this affects to battery. I have suspicios that it drains it quickly. What my application does is opening socket connection and then reading it... for one day, for two days, for week.

Also I'm not sure on this loop:

Code:
    private String read(InputStream is)
    {
        Date d1 = new Date();
        StringBuffer sb = new StringBuffer();
        int c = 0;
        try
        {
            do
            {
                int l = is.available();                
                if(l>0)
                {
                    if(l>2048) l = 2048;
                    byte[] b = new byte[l];
                    int len = is.read(b);
                    if(len > 0)
                    {
                        String newStr = new String(b, 0, len);                        
                        sb.append(newStr);                        
                    }                
                    
                    sb = resolveEvent(sb);
    
                    if (c == -1)
                    {
                        Date d2 = new Date();
                        System.out.println("EOF [" + d2.getTime() + "] " + sb.toString());
                        System.out.println("===== mills:" + (d2.getTime() - d1.getTime()));
                        MySettings.sendLog();
                        return null;
                    }
                }
                else
                    MySettings.delay(100);
            }
            while (true);
        }
        catch(ConnectionClosedException ex)
        {
            MySettings.handleException(ex, "Receiver.read_1");
            if(MySettings.getAppInstance().security.isLoggedIn)
                NetworkManager.getInstance().checkConnection();
        }
        catch (Exception ex)
        {
            MySettings.handleException(ex, "Receiver.read");
        }
        return null;
    }
Please advice.
Offline  
Old 10-30-2008, 09:49 PM   #2 (permalink)
Thumbs Must Hurt
 
Join Date: Apr 2008
Model: 8130
PIN: N/A
Carrier: US Cellular
Posts: 82
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Will it actually be receiving data continuously, or does the server only generate data sporadically?
Offline  
Old 11-01-2008, 03:27 AM   #3 (permalink)
New Member
 
Join Date: Jul 2008
Model: 8320
PIN: N/A
Carrier: MTS
Posts: 5
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Dan, thanks! The software receives data sporadically. This is a chat and mail application. It is essential to keep connection to the server.

For me this question is general. Surely I'll find a workaround for this, say I'll disconnect from the server and will receive vital notifications by e-mail. But it sounds stange, since applications like gTalk, MSN, JiveTalk, etc. keep connection and the nature of BB software is to stay online. There should be a solution.
Offline  
Old 02-09-2009, 07:25 AM   #4 (permalink)
New Member
 
Join Date: Jul 2008
Model: 8320
PIN: N/A
Carrier: MTS
Posts: 5
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I would like to re-iterrate. Can anyone help?
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.