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

Reply
Developer
Aviator168
Posts: 709
Registered: ‎09-10-2009
My Device: 8520, 8900, 9000, 9300, 9650, 9700, 9780, 9800, 9810, 9900, 9930

Re: TCP connections suck ... any of them

import java.io.*; import javax.microedition.io.*; import net.rim.device.api.ui.*; import net.rim.device.api.ui.component.*; /** * */ class SoInThread extends Thread { MyScreen _screen = null; int rPCount = 0; SoInThread() { _screen = ((SockTestMain)UiApplication.getUiApplication()).getScreen(); } /* thread implementation - just read the data and put it on the screen */ public void run() { char [] buf = new char[32000]; _screen.updateDisplay("Opening Connection...\n"); String url = "socket://192.168.3.7:4001;interface=wifi"; // String url = "socket://server:4001;deviceside=true"; try { connection = (SocketConnection)Connector.open(url); } catch (IOException e) { _screen.updateDisplay(e.toString()); } _screen.updateDisplay("Connection open\n"); try { _in = new InputStreamReader(connection.openInputStream()); } catch (IOException e) { } while (true) { try { _in.read(buf, 0, 32000); } catch (IOException e) { try { _in.close(); connection.close(); } catch (IOException ww) {} return; } rPCount++; } } }

 

Here is thread code. It is very simple.
Please use plain text.
New Developer
maltic
Posts: 49
Registered: ‎09-25-2009
My Device: Not Specified

Re: TCP connections suck ... any of them

Hi,

thanks for the code. This does not work for me. I used socket connections before and the connections started to hang or disconnected sometimes without any specific reason. But I have to say that the code was somehow more complicated, e.g. sending bytes, receiving bytes etc. You have only one simple stream. Please try to open and close the socket connections in and endless loop. This would be more like my app.

M.

Please use plain text.
Developer
peter_strange
Posts: 19,609
Registered: ‎07-14-2008
My Device: Not Specified

Re: TCP connections suck ... any of them

Just to give you the results of my testing.  I slightly modified the code so that it would compile in 4.2.1 (my standard test bed, there was some 4.6 specific code in the percent calculation.  Here is the changed code:

                            int percent = (int)(100.0D/vTotalSize*vTotalRead);
                            if ( percent < 0 ) {
                                percent = 0;
                            } else
                            if ( percent > 99 ) {
                                percent = 100;
                            }
                            oGaugeField.setValue(percent);

 

I also code either deviceside=true or interface=wifi, not both, so my connection for WiFi is just ";interface=wifi".  But I don't think that makes any difference. 

 

Anyway on the 4.2.1 Sim (8800) code runs forever.  When I install 4.2.1 compiled version on Bold and 8900 Curve, runs forever. (well I say forever, I left it running on the Curve for over 4 hours, which is not quite forever).  It is downloading a 6 Meg Zip file (the first thing I found that was a suitable size), from a real web site hm, just realised, that could be costing us a fortune in download charges.... ah well). 

 

So then I tried it in 4.6.  When running a 4.6 Simulator, the 4.2.1 compiled version hangs on the first run.  When recompiled using 4.6, it hangs on the first run.  Never gets above 50%, lowest stop was on 5%,  But I've not done much testing. 

 

However the 4.6 compiled versions are still running fine on the Bold and the Curve - have been going at least 30 minutes, Curve is on loop 56 with over 300 MB data downloaded.

 

Sorry I don;t think that helps much, other than confirm, as far as I can tell, that there is a problem with the Bold Simulator, at least the one packaged with JDE 4.6, 

 

If you would like me to test anything else let me know.  I'm going to change the program slightly and do some WiFi performance testing for the Curve and the Bold.  Looks like the Curve is faster.

Please use plain text.
New Developer
maltic
Posts: 49
Registered: ‎09-25-2009
My Device: Not Specified

Re: TCP connections suck ... any of them

Hi,

 

thanks for testing. I have compiled the app using 4.6.1. I will try 4.6 instead. Which OS are you running on Curve and Bold?

 

M.

Please use plain text.
New Developer
maltic
Posts: 49
Registered: ‎09-25-2009
My Device: Not Specified

Re: TCP connections suck ... any of them

I recompiled with 4.6, applied your "percent"-changes and removed deviceside=true. Running on the Curve, it stopped at loop 16, so there is not much improvement here. I will forward this to the RIM developer´s side and check if they can help me. Thanks again for your help!!

Please use plain text.
Developer
peter_strange
Posts: 19,609
Registered: ‎07-14-2008
My Device: Not Specified

Re: TCP connections suck ... any of them

Curve OS, 4.6.1.199, managed up to 180 KBs per sec

Bold OS, 4.6.0.126 (an old one), managed up to 120 KB's per sec

 

Re performance, my test can only be used for comparative figures, from this test you can not say that these devices have these speeds when using WiFi.  What you can say is the Curve is about 50% faster.

 

I still like my Bold better.  Trackball on Curve is better, but the keyboard on the Bold is best for my fat fingers.

Please use plain text.
Developer
Aviator168
Posts: 709
Registered: ‎09-10-2009
My Device: 8520, 8900, 9000, 9300, 9650, 9700, 9780, 9800, 9810, 9900, 9930

Re: TCP connections suck ... any of them

peter, was your test using direct tcp or http? 3G or wifi? Oneway transmission or twoway transmission?
Please use plain text.
Developer
peter_strange
Posts: 19,609
Registered: ‎07-14-2008
My Device: Not Specified

Re: TCP connections suck ... any of them

I was using the test code supplied by the OP - link to it is in this post:

 

http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&view=by_date_ascending&messa...

 

I made minor changes as described in my last but one post.

 

So, to answer your questions:

direct tcp or http? - http

3G or wifi? - wifi

Oneway transmission or twoway transmission?  - one way, download (to device) only.

Please use plain text.
Developer
peter_strange
Posts: 19,609
Registered: ‎07-14-2008
My Device: Not Specified

Re: TCP connections suck ... any of them

Stop Press, just upgraded the Bold to 4.6.0.266 and it is now faster than the Curve, by about 33%, managing upto 200KB per second.  It also seems a lot more reliable on WiFi.  I'm impressed with the upgrade!
Please use plain text.
New Developer
maltic
Posts: 49
Registered: ‎09-25-2009
My Device: Not Specified

Re: TCP connections suck ... any of them

It is unbelievable how much time one (now two) can invest in such problems. It´s now about 10 days ...but there are improvements: a colleague of mine has tested HTTPTester2 (also on the website, see above) on his internal wifi network with a Linux apache server - no problems at all!! So I went to his appartment and tested with my Curve ...21 loops, no problems. I brought my W7 laptop with me with IIS7 - same problem - on this Flip and on my Curve. Is this problem related to Windows 7 or Windows? Did MS change something in the TCP stack RIM is not compatible with ...? I will drive home now, download a Linux Live CD and keep on testing ...

 

... RIM - any comments on this? BTW: Why is the Developer Issue Tracker down :smileywink: ??

Please use plain text.