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


USB Type-C Meter Tester Digital Multimeter Current Voltage Power Detector +Cable picture

USB Type-C Meter Tester Digital Multimeter Current Voltage Power Detector +Cable

$19.98



Electricity Usage Energy Monitor Plug Power Watt Voltage Meter Analyzer Socket picture

Electricity Usage Energy Monitor Plug Power Watt Voltage Meter Analyzer Socket

$12.99



100A AC Meter Ammeter Volt Energy Voltage Power LCD Display Monitor Panel picture

100A AC Meter Ammeter Volt Energy Voltage Power LCD Display Monitor Panel

$17.09



AVR SX460 Automatic Voltage Volt Regulator Replacement For Stamford Generator picture

AVR SX460 Automatic Voltage Volt Regulator Replacement For Stamford Generator

$16.32



Renogy 500A Battery Monitor High and Low Voltage Programmable Alarm 500A Shunt picture

Renogy 500A Battery Monitor High and Low Voltage Programmable Alarm 500A Shunt

$131.99



Power Queen 500A Battery Monitor with Shunt High Low Voltage Programmable Alarm picture

Power Queen 500A Battery Monitor with Shunt High Low Voltage Programmable Alarm

$57.99







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