Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
New Developer
Posts: 2
Registered: ‎12-08-2008
My Device: Not Specified

Lost data on network connection drop

I have an application that performs 2-way data transfer over a TCP socket (devicesie=true).  I want to make sure that I don't lose any data that I sent, i.e. if the network connection closes abruptly, I want to detect it and buffer my data to be sent later.

 

My test is turning off the radio on the blackberry device (8820, OS 4.2).

 

When I have a constant stream of outbound data (about 100 bytes every sec), I don't get any exceptions thrown immediately after the disconnect, so there is no way for me to detect the problem and recover the data.  This data also never gets to the server (confirmed with wireshark).

 

Eventually (within a second - on a second write attempt), an exception gets thrown and I can reconnect and resend.

 

I've tried setting the outbound (and inbound) socket buffers to 50 bytes, but I still lose data (although anecdotally less frequently).

 

I also call .flush() immediately after each .write(char[] b).

 

 

Has anyone encountered this problem?

 

How do I make sure that no data gets lost in these cases?

 

Thanks.

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Lost data on network connection drop

You can packetize the data and serialize the packets. If a packet fails you can resend the last packet and the current packet.

 

On the receiving side, the "catcher" needs to ignore a duplicate packet (same serial number).

 

There are more complex ways to do this, but this one is simple to implement and fairly foolproof.

 

 

 

 

New Developer
Posts: 2
Registered: ‎12-08-2008
My Device: Not Specified

Re: Lost data on network connection drop

Thanks for the suggestion, but I am using a standard protocol with a 3rd party server (XMPP). My data is already being sent in packets (text messages).  Resending the previous message does not work either, because several messages can get lost, and I don't know how may actually didn't make it through (it's not just the last one).

 

Of course, some type of an application layer ACK would do the job, but I can't do that in this case.