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


iPhone 13 12 11 PRO MAX XR XS 8/7/6 Fast Charger USB Data Cable cord 10 feet/3M picture

iPhone 13 12 11 PRO MAX XR XS 8/7/6 Fast Charger USB Data Cable cord 10 feet/3M

$4.99



OEM iPhone 11 PRO X/XR XS MAX 8/7 PLUS Fast Charging USB Cable 10 Feet & 6 Feet  picture

OEM iPhone 11 PRO X/XR XS MAX 8/7 PLUS Fast Charging USB Cable 10 Feet & 6 Feet

$2.99



10 Foot/3M iPhone 12/11 PRO MAX X/10 XR XS 8/7 FAST Charging USB LONG Cable cord picture

10 Foot/3M iPhone 12/11 PRO MAX X/10 XR XS 8/7 FAST Charging USB LONG Cable cord

$4.98



10 Feet/3M For iPhone 13 12 11 PRO MAX MINI  X XR XS 8 7 Fast Charging USB Cable picture

10 Feet/3M For iPhone 13 12 11 PRO MAX MINI X XR XS 8 7 Fast Charging USB Cable

$5.00



Genuine A1417 OEM Battery Apple Macbook Pro 15 Retina A1398 Mid 2012 Early 2013 picture

Genuine A1417 OEM Battery Apple Macbook Pro 15 Retina A1398 Mid 2012 Early 2013

$37.90



OEM Battery for MacBook Pro 17

OEM Battery for MacBook Pro 17" A1309 A1297 Early 2009 Mid 2009 2010 MC226

$36.90







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