BlackBerry Forums Support Community

BlackBerry Forums Support Community (http://www.blackberryforums.com/)
-   Developer Forum (http://www.blackberryforums.com/developer-forum/)
-   -   Stream problem in Blackberry 8820 (http://www.blackberryforums.com/developer-forum/122218-stream-problem-blackberry-8820-a.html)

hithayath_sait 03-26-2008 05:36 AM

Stream problem in Blackberry 8820
 
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.

bdowling 03-28-2008 02:45 PM

Can you post a code sample?

hithayath_sait 03-28-2008 03:36 PM

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.

bdowling 03-28-2008 04:37 PM

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: http://www.blackberryforums.com/deve...simulator.html

hithayath_sait 03-29-2008 04:45 AM

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.

bdowling 03-29-2008 07:45 AM

In your first post you said you have code that is fast, but you're getting an exception. Can you post that code?

hithayath_sait 03-31-2008 12:08 AM

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.??

balajimani 04-30-2008 01:09 AM

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.

hithayath_sait 04-30-2008 01:45 AM

Can u please post ur detailed code, so that i can try to give a solution.


All times are GMT -5. The time now is 06:13 AM.

Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.