BlackBerry Forums Support Community

Closed Thread
LinkBack Thread Tools
Old 11-20-2007, 02:45 AM   #1 (permalink)
Thumbs Must Hurt
Join Date: Jun 2007
Model: 8800
Carrier: GPRS
Posts: 68
Post Thanks: 0
Thanked 0 Times in 0 Posts
Question It's strange in receiving the data from server

Please Login to Remove!


I have written a small program to receive the data from server in 1024 bytes every time on BB simulator, and find that the simulator will out of work after receiving a few minutes.The time is not the same, and the total data received is from 30M to 120M differently.
My code is as follow:
public void sockettest()  
        StringBuffer buffer = new StringBuffer();            
        int count = 0;        
        boolean RECE = true;    
        int LENGTH = 1024;
        int n = 0;   
        int total = 0;  
        byte[] tempMemo = new byte[LENGTH]; 
        int revc = 0;         
            SocketConnection sock = (SocketConnection),Connector.READ);           
            sock.setSocketOption(SocketConnection.LINGER, 5);                 
            DataInputStream inStream =  sock.openDataInputStream();          
            System.out.println("Starting !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");                 
                revc = 0;
                //make sure to receive 1K every time
                while(revc < tempMemo.length)
                    int coun =,revc,(tempMemo.length-revc));                        
                    if( coun<0) break;
                    revc += coun;
                total += revc;      
                System.out.println("The value of n is :" + (++n) + "   "+total+"   "+tempMemo.length);
        catch(Exception e_exp1)
The server is sending data continuing and the client is just need to receive the data continually.

So what's the problem of the client program? If you have good idea,please let me know! Or if you have good examples on receiveing large data, please show it to me !
Thank you very much!!

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