BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 05-11-2007, 02:48 AM   #1
abahadilah
New Member
 
Join Date: May 2007
Model: 7100T
PIN: N/A
Carrier: test
Posts: 1
Default Connection latency

Please Login to Remove!

i have develop client application in blackberry which is connect and then waiting data from server. When trying in emulator the latency is none, but when deployed to device using GPRS, the latency is huge, and because the app suppose to be real time, it become an issue. Do you have solution for that.

here are the snapshot of connection code:

public void run() {
try {
iSockInputStrm = iEngine.iSocket.openInputStream();
while (! stop) {
try {
int ch;
char cc;
boolean isTail = false;
StringBuffer buf = new StringBuffer();
while((ch = iSockInputStrm.read()) != -1) {
cc = (char) ch;
buf.append(cc);
if (isTail) {
if (cc != TypeDef.DATA_TAG) {
// process packet
buf.delete(0, buf.length());
}
isTail = false;
}

if (cc == TypeDef.TAIL_CHAR) {
isTail = true;
}

try {
Thread.sleep(1);
}
catch(Exception e) {
}
}

try {
Thread.sleep(1);
}
catch(Exception e) {

}
}
catch (Exception e) {
break;
}
}
}
catch (Exception e1) {
}
}
Offline  
Old 05-13-2007, 08:53 AM   #2
Skipper_Joe
Talking BlackBerry Encyclopedia
 
Skipper_Joe's Avatar
 
Join Date: Jan 2007
Location: Kharkov, Ukraine
Model: 8300
Carrier: N/A
Posts: 237
Default

Couple of common strategies:
1) Send your updates to server asynchronously so it will not affect responsiveness of UI.
2) Cache data, downloaded from server, on your device. It allows you not to repeat requests to server and increase response time to user in some cases.
Offline  
Old 05-15-2007, 12:37 PM   #3
egalexe
Knows Where the Search Button Is
 
Join Date: Feb 2007
Model: 9000
Carrier: SFR
Posts: 48
Default

Hi,


I had some troubles too to read using socket on BB.
What I recommend is the following:

firstChar = (char)inputStream.read(); //Blocking command
nbr_byte = inputStream.available();
byte_result = new char[nbr_byte + 1];
byte_result[0] = firstChar;
for (int cpt = 0; cpt < byte_result; cpt++) {
byte_result[cpt+1] = inputStream.read();
}

//Don't forget to use thread.

Hum perhaps it can be customized, but
1/read[1]
2/available
3/read[n]
seems to be the good solution.
Offline  
Old 05-27-2007, 02:48 PM   #4
Mark Rejhon
Retired BBF Moderator
 
Mark Rejhon's Avatar
 
Join Date: Aug 2004
Location: Ottawa, Ontario, Canada
Model: Bold
Carrier: Rogers
Posts: 4,870
Default

Quote:
Originally Posted by abahadilah View Post
i have develop client application in blackberry which is connect and then waiting data from server. When trying in emulator the latency is none, but when deployed to device using GPRS, the latency is huge, and because the app suppose to be real time, it become an issue. Do you have solution for that.
Burst the data out in 500 millisecond bursts at the minimum -- GPRS can only transmit about one to three packets per second, so if you have a realtime application (i.e. telnet), you should buffer all your packet transmissions and burst them out on a 500 millisecond timer (approximately). Either for incoming and outgoing data where possible. That way, it doesn't end up lagging for more than 1 second (which can happen if you rapid-fire transmit many packets. You can transmit up to about 5 kilobytes per second over GPRS, but to do so, you need to burst them out efficiently. GPRS is very bottlenecked in terms of number of packets per second. In fact, you can get less latency bursting a single 1Kbyte packet, than transmitting three separate 100-byte packets!

Server side programming: Make sure the server bursts out the data all at once, so the BlackBerry can read it all at once, quickly
Client side programming: Make sure the client bursts out all data necessary, in as short time period..

Regardless of the technique, you still have appoximately 600 to 1000 milliseconds of unavoidable latency -- but at least it won't be much worse than that (which can happen if you transmit multiple packets in rapid-fire fashion)
__________________
Thanks,
Mark Rejhon
Author of XMPP extension XEP-0301:
www.xmpp.org/extensions/xep-0301.html - specification
www.realjabber.org - open source

Last edited by Mark Rejhon; 05-27-2007 at 02:53 PM..
Offline  
Closed Thread



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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


OEM Dell 3310 2 in 1 LCD Touch Screen D2TNH NV133FHM-T00 06GHX8 picture

OEM Dell 3310 2 in 1 LCD Touch Screen D2TNH NV133FHM-T00 06GHX8

$54.00



OEM Dell XPS 8910 8920 8930 Alienware Aurora R5 R6 R7 Front Cooling Fan 7M0F5 picture

OEM Dell XPS 8910 8920 8930 Alienware Aurora R5 R6 R7 Front Cooling Fan 7M0F5

$13.81



Dell OEM Latitude Rugged Extreme 7404 GPS Antenna Junction Cable Cable KMX0M picture

Dell OEM Latitude Rugged Extreme 7404 GPS Antenna Junction Cable Cable KMX0M

$2.95



Dell OEM Latitude Rugged Extreme 7404 Ribbon Cable for ExpressCard Cable G52B00 picture

Dell OEM Latitude Rugged Extreme 7404 Ribbon Cable for ExpressCard Cable G52B00

$9.95



Genuine OEM Dell 2375 B2375dnf B2375dfw 110V Fuser fixing N41P2 sku 724-BBCI picture

Genuine OEM Dell 2375 B2375dnf B2375dfw 110V Fuser fixing N41P2 sku 724-BBCI

$94.99



DELL 330-6581 3306581 725-10229 OEM LAMP FOR 1510X 1610HD 1610X  - Made By DELL picture

DELL 330-6581 3306581 725-10229 OEM LAMP FOR 1510X 1610HD 1610X - Made By DELL

$39.98







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