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
PIN: N/A
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!

Hi,everyon:

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:
Code:
public void sockettest()  
    {
        StringBuffer buffer = new StringBuffer();            
        buffer.append("socket://172.16.229.142:6125;deviceside=true");
        int count = 0;        
        boolean RECE = true;    
        int LENGTH = 1024;
        int n = 0;   
        int total = 0;  
        byte[] tempMemo = new byte[LENGTH]; 
        int revc = 0;         
        try
        {  
            SocketConnection sock = (SocketConnection)Connector.open(buffer.toString(),Connector.READ);           
            sock.setSocketOption(SocketConnection.LINGER, 5);                 
            DataInputStream inStream =  sock.openDataInputStream();          
            System.out.println("Starting !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");                 
            while(RECE)
            {  
                revc = 0;
                //make sure to receive 1K every time
                while(revc < tempMemo.length)
                {                    
                    int coun = inStream.read(tempMemo,revc,(tempMemo.length-revc));                        
                    if( coun<0) break;
                    revc += coun;
                }                    
                total += revc;      
                System.out.println("The value of n is :" + (++n) + "   "+total+"   "+tempMemo.length);
            }
            inStream.close();          
            sock.close();
         }
        catch(Exception e_exp1)
        {
            System.out.println(e_exp1.toString());   
        }  
    }
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!!
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

2 Pack Apple Earpods OEM Original Stereo Headphones w/Control-White MD827LL/A
$20.0
2 Pack Apple Earpods OEM Original Stereo Headphones w/Control-White MD827LL/A picture(C21) Genuine OEM Apple AC Cord
$25.0
(C21) Genuine OEM Apple AC Cord picture4 x Black Inkjet Cartridges Non-OEM Alternative For T1291
$11.95
4 x Black Inkjet Cartridges Non-OEM Alternative For T1291 pictureNew OEM Lightning to USB Cable Charger Data Cord for iPhone 5 5S 5C 6 6 Plus
$2.7
New OEM Lightning to USB Cable Charger Data Cord for iPhone 5 5S 5C 6 6 Plus  pictureOEM Genuine Original for Apple iPhone 5s 6s 6+ Lightning USB Data Cable Charger
$2.7
OEM Genuine Original for Apple iPhone 5s 6s 6+ Lightning USB Data Cable Charger  picture






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