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
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: HTTP connection limit

aashuj - splitting hairs(?), I would call what you are describing 'blocking' rather than buffering, i.e. taking a number of smaller amounts of data and putting these together in large chunks before sending.  I had assumed (probably incorrectly now I re-read the Thread) that Raiden would be doing that already, i.e. had 19Kb of data to send and was just working out how best to send send it.  In this circumstance, I didn't think blocking (or buffering) would help. 

 

Raiden

 

Apologies if I have got it wrong.  Sending your data in multiple small chunks rather than one large one could have a significant impact on performance and in this situation, blocking/buffering or multiple connections well probably help you.  In my testing, it takes about 2 seconds on a socket connection to send a small and acknowledge a message over GPRS (YMMV).  Multiply that by 100 and you have a very slow data download.

 

However if you are already sending one large packet, then I wouldn't bother reblocking it in an attempt to optimism the performance of the network.  And, as noted, in this circumstance, I don't think multiple connections will help either. 

 

 

Developer
Posts: 490
Registered: ‎07-16-2008
My Device: Not Specified

Re: HTTP connection limit

Ok. I got your ideas.

 

I will test it by two ways. The first one is, using one connection in thread.

Second one is, using 3 connections in thread.

 

Real problem is I haven't BB device.Smiley Wink So, I gonna use simulator JDE.

 

Maybe If I have chance to test on real device, I will report the result in the forum.

 

Tnx guys, Have a nice day.Smiley Happy

New Developer
Posts: 6
Registered: ‎09-08-2008
My Device: Not Specified

Re: HTTP connection limit

Please try this code:

 

 

 

httpConnector = (HttpConnection)Connector.open(URL);
          
            //get status
            int status = httpConnector.getResponseCode();
            httpConnector.getEncoding();
            //get content length
            float contentLength = httpConnector.getLength();
            if (status == HttpConnection.HTTP_OK){
                //openInputStream initiates the connection
                in = httpConnector.openInputStream();               
                //Buffered Fetch
                byte[] bytes = new byte[2048];
                int len=0;
                float totalBytesFetched = 0;
                ByteArrayOutputStream bytesArray = new ByteArrayOutputStream();
                while ((len = in.read(bytes)) != -1) {
                    //append incoming characters to the buffer

bytesArray.write(bytes,0,len);                   

}               
              
            }       
       

 

Thanks--

 

Highlighted
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: HTTP connection limit

If you are performance testing the network, I suspect you are wasting your time doing this on a simulator.