BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 03-26-2008, 05:36 AM   #1 (permalink)
Thumbs Must Hurt
 
Join Date: Mar 2008
Model: 8820
PIN: N/A
Carrier: Airtel
Posts: 51
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Stream problem in Blackberry 8820

Please Login to Remove!

Hi Friends,

I have developed an application which sends data thru WiFi (socket connection) and receives acknowledment.

The process is like:

1. Opened a socket connection
2. Opened an outputstream with respect to socket conn.
3. Opened an inputstream with respect to socket conn.
4. Receives first acknowledment msg from server.
5. Sending data and receiving ack msg.

I have the both input and output streams opened once the connection is done.

Using the streams i am reading and writing the data.

I used the "local"(Within the method) DataInputStream object to read the data. DataInputStream is created by passing inputStream object in constructor of DataInputStream.

The problem is, for reading just 8 bytes it is taking nearly above 10 secs, if dont close DataInputStream after readFully() method.

If i close DataInputStream after readFully() method, reading data is improved like 1 sec but i am getting "ConnectionCloseException".

Please suggest me a solution, how to overcome it.

Thanks in Advance.
Offline  
Old 03-28-2008, 02:45 PM   #2 (permalink)
Thumbs Must Hurt
 
Join Date: Jan 2007
Model: 8800
Carrier: Orange
Posts: 181
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Can you post a code sample?
Offline  
Old 03-28-2008, 03:36 PM   #3 (permalink)
Thumbs Must Hurt
 
Join Date: Mar 2008
Model: 8820
PIN: N/A
Carrier: Airtel
Posts: 51
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

public SocketConnection getConnection() {
long startTime = 0;
try {
if(sc == null) {

sc = (SocketConnection) Connector.open "socket://"+Utils.getIPAddress()+":5080;deviceside=true;inte rface=wifi", Connector.READ_WRITE);
sc.setSocketOption(SocketConnection.KEEPALIVE, 1);
sc.setSocketOption(SocketConnection.SNDBUF, ((320 * 240 * 2)+20));

}
} catch (ConnectionClosedException e) {
} catch (IOException ioe) {
} catch (Exception e) {
}
return sc;
}


public void writeSocket(byte[] data) {
try {
os.write(data, 0, data.length);
os.flush();
} catch (IOException ioe) {

} catch (Exception e) {

}
}


public byte[] readSocket(int size) {
byte[] data = new byte[size];
try {

is.read(data, 0, data.length);
} catch (IOException ioe) {

} catch (Exception e) {

}
return data;
}


These are my method which does the main trasfer operation.

I am looking forward your suggestion to have good perfomance at transfer.

Last edited by hithayath_sait : 03-28-2008 at 03:41 PM.
Offline  
Old 03-28-2008, 04:37 PM   #4 (permalink)
Thumbs Must Hurt
 
Join Date: Jan 2007
Model: 8800
Carrier: Orange
Posts: 181
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

That would have been much easier to read if you wrapped with it CODE tags!

I take it that the code you posted is the code that works but takes a long time? Can you post the code that is fast but doesn't work too, this time in CODE tags

The ConnectionManager class I wrote looks very similar to your code, so may be of some help. I posted in the forum: Max IO Connections on device but not simulator?
Offline  
Old 03-29-2008, 04:45 AM   #5 (permalink)
Thumbs Must Hurt
 
Join Date: Mar 2008
Model: 8820
PIN: N/A
Carrier: Airtel
Posts: 51
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

The code which i posted is working but not fast. Can you help how to improve the throughput of transfer.

I had a look at link you provided. Next time i will definitely put the code in the respective tags.

Please suggest me solution to improve performance.

Thanks in Advance.
Offline  
Old 03-29-2008, 07:45 AM   #6 (permalink)
Thumbs Must Hurt
 
Join Date: Jan 2007
Model: 8800
Carrier: Orange
Posts: 181
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

In your first post you said you have code that is fast, but you're getting an exception. Can you post that code?
Offline  
Old 03-31-2008, 12:08 AM   #7 (permalink)
Thumbs Must Hurt
 
Join Date: Mar 2008
Model: 8820
PIN: N/A
Carrier: Airtel
Posts: 51
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes thats true, earlier i got an exception and i have rectified it. After that the problem was in speed of transfer.

Now i have optimised to 1 sec for 150000 bytes transfer. I am looking for further reduction in transfer time.

But i come across that the BB 8820 device capacity is only 54 - 60Kb

Is that true about the transfer rate.??
Offline  
Old 04-30-2008, 01:09 AM   #8 (permalink)
New Member
 
Join Date: Apr 2008
Model: 8670
PIN: N/A
Carrier: Sprint
Posts: 4
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Socket Connection Problem

Hi,

I doing some application using Blackberry JDE. I am unable to create Socket connection to make a server connection from client and server.

Here is the sample code.

ConnectionManager connMGR = new ConnectionManager(URL);
StreamConnection conn = connMGR.getConnection();
daOut = connMGR.getDataOutputStream();

I am unable to make socket connection using this and my MDS is also on.

Kindly let me know if any one done with this.

Thanks,
Bala.
Offline  
Old 04-30-2008, 01:45 AM   #9 (permalink)
Thumbs Must Hurt
 
Join Date: Mar 2008
Model: 8820
PIN: N/A
Carrier: Airtel
Posts: 51
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Can u please post ur detailed code, so that i can try to give a solution.
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





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