×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Oct 2007
    Posts
    24

    DataOutputStream not closing

    Hi all,
    I have developed a j2me application which sends a request to the server and gets response repeatedly. I have used DataOutputStream to write.
    The application is getting stuck some times while closin g the DataOutputStream. And I dont even get any exception.
    Has any one faced the same trouble. I have read a post in the forum ( http://discussion.forum.nokia.com/fo...d.php?t=110420 ) which explains the same problem but got no reply.
    Please share some ideas.

  2. #2
    Registered User
    Join Date
    Mar 2008
    Posts
    116

    Re: DataOutputStream not closing

    i used
    OutputStream os = ssc.openContentOutputStream();
    os.write(".....");
    os.close();

    it worked perfectly.

  3. #3
    Registered User
    Join Date
    Oct 2007
    Posts
    24

    Re: DataOutputStream not closing

    Hi apus29
    I am establishing a http connection and writing the output stream. SipClientConnection is not useful for http connections. Do you have any other solution?
    Any one with same exp please do reply.
    Thanx in advance.

  4. #4
    Super Contributor
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,191

    Re: DataOutputStream not closing

    Are you flushing the stream after writing and before closing?

    Hartti

  5. #5
    Registered User
    Join Date
    Oct 2007
    Posts
    24

    Re: DataOutputStream not closing

    Hi hartti,
    yes I am flushing the stream. Here is the sample code :
    int count=100;
    for(int i=0;i<count;i++){

    HttpConnection hcon=(HttpConnection)Connector.open("http://../myservlet);
    hcon.setRequestMethod(HttpConnection.POST);
    hcon.setRequestProperty("User-Agent","Profile/MIDP-2.0 Configuration/CLDC-1.1" );
    hcon.setRequestProperty("Content-Language", "en-US" );
    hcon.setRequestProperty("Accept", "application/octet-stream" );
    hcon.setRequestProperty("Connection", "close" );
    String XMLFile;(size would be 500k)
    //code to gen XMLFile

    DataOutputStream dout=hcon.openDataOutputStream();

    if(dout!=null)
    dout.write(XMLFile.getBytes);

    dout.flush();
    dout.close();
    DataInputStream din=hcon.openDataInputStream();
    //read the xml sent by the server and has some process(size would be 5k)

    }//for loop
    Last edited by veda_scient; 2008-05-28 at 13:09.
    veda

Similar Threads

  1. DataOutputStream not closing on N95
    By sreekanthbellur in forum Mobile Java Networking & Messaging & Security
    Replies: 0
    Last Post: 2007-06-19, 14:44
  2. Application closing..!!!
    By techietintu in forum Symbian
    Replies: 4
    Last Post: 2007-01-23, 08:55
  3. Locked-up closing an InputStream of a Socket Connection
    By tony.sung in forum Mobile Java Networking & Messaging & Security
    Replies: 2
    Last Post: 2006-10-27, 21:47
  4. Urgent help on closing connection in nokia N70
    By siva_guduru in forum Mobile Java General
    Replies: 0
    Last Post: 2006-04-26, 12:13
  5. network streams closing themselves?
    By dreamix in forum Mobile Java Networking & Messaging & Security
    Replies: 1
    Last Post: 2005-04-12, 18:02

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×