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

New Developer
Posts: 8
Registered: ‎10-10-2008
My Device: Not Specified

why my direct socket speed is so low?

[ Edited ]

Blackberry BOLD on rogers canada.

JDE 4.6


 final void writeln(String s,OutputStreamWriter out) throws IOException  {
            out.write(s+ "\r\n");  out.flush();

         final String readln(InputStreamReader in)  throws IOException {
            char ch=0;
            StringBuffer sb = new StringBuffer();
            return sb.toString();

         private int exchange(InputStreamReader _in, OutputStreamWriter _out,String data,double[] rs) throws IOException
            // Cache the length locally for better efficiency.
            int length = data.length();
            // Create an input array just big enough to hold the data (we're expecting the
            // same string back that we send).
            double stime = System.currentTimeMillis();
            double TotalTime = System.currentTimeMillis() - stime;
            // Read character by character into the input array - we're only reading length
            // characters.
            stime = System.currentTimeMillis();
            TotalTime = System.currentTimeMillis() - stime;
            return length;

        private boolean SocketTest(StringBuffer raw,String URL)
            InputStreamReader _in;
            OutputStreamWriter _out;
            LineReader in;
            StreamConnection connection = null;
                connection = (StreamConnection)Connector.open(URL);
                _in = new InputStreamReader(connection.openInputStream());
                _out = new OutputStreamWriter(connection.openOutputStream());
                double[] t=new double[2];
                int size = 0;
                // Send the HELLO string.
                // Execute further data exchange here...
                for(int i=0;i<100;i++)
                    if(i % 10==0)updateContent("TCP testing "+i+"%...");
                // Send the GOODBYE string.



URL is "socket://badev.liveblockauctions.com:7;deviceside=true;apn=internet.com;tunnelauthusername=;tunnelauthpassword="

DATA is "1234567890123456789012345678901234567890".


I got 0.6K bytes/s up and .3 down.

My phone is on 3G mode and HTTP test give me 35K bytes speed from same server.

Why socket speed is so low? Do I do anything wrong?


I mean using default linux echo server to do the test.


Message Edited by alxwang on 10-14-2008 10:46 PM
BlackBerry Development Advisor
Posts: 15,784
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: why my direct socket speed is so low?

I recommend running the test again but send a larger amount of data.  This should give you more accurate throughput figures since it'll reduce the affect the connection setup overhead has on your test.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: why my direct socket speed is so low?

More to the point of finding the limitations, it may help to distinguish things like latency and round trip delay from bandwidth.

It is also helpful to make sure you don't just have a buffering problem ( someone is holding packets waiting to

assemble a larger unit before responding) and use a packet capture program to see what you actually get when.


I'm doing timing tests on http connections and first try to estimate the latency, which of course can be dominated by

server response time. But, if you have the ability, you probably want to do incremental tests and look at how much

longer it takes to send 20k than 10k for example. You should probably end up with two numbers ( besides things

like how many connections you drop before completion ) - latency and sustainable BW.

New Developer
Posts: 8
Registered: ‎10-10-2008
My Device: Not Specified

Re: why my direct socket speed is so low?

But my design need real time 8 bytes data from server to phone and 4 bytes data on the other direction.

So does that mean BB is not suit for this kind of application?


Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: why my direct socket speed is so low?

There could be problems with the TCP stack but offhand I'd have to assume you are running into

normal limitations of wireless IP. There is a bunch of other stuff that gets sent,








I'm not sure what you mean by real time but sure, you can usually force buffer flushes to send whatever you have

when you have it.


However, I would consider a more tolerant design and try to make use of buffering if possble to send bigger chunks

of stuff and don't count on keeping a socket alive indefinitely.