×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Regular Contributor
    Join Date
    Oct 2008
    Posts
    56

    Closing connection?

    my MIDP 2.0 app connects to the internet , but after the application sent it's query to the server the phone wont close the internet connection . How do i make the phone, close that internet connection ?

  2. #2
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Thumbs up Re: Closing connection?

    Hi,
    Exactly what is happening and what you want..
    Are the connections opening continuously ..or what ..
    Put more information on this..
    Thanks,
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  3. #3
    Regular Contributor
    Join Date
    Jul 2008
    Location
    Faridabad(Delhi NCR)
    Posts
    343

    Re: Closing connection?

    R u getting ANy Exception...if it is cuming then tell us......
    Anshu Chauhan
    J2me Developer

  4. #4
    Nokia Developer Champion
    Join Date
    Sep 2007
    Posts
    915

    Re: Closing connection?

    Quote Originally Posted by mikecotic View Post
    my MIDP 2.0 app connects to the internet , but after the application sent it's query to the server the phone wont close the internet connection . How do i make the phone, close that internet connection ?
    Are you trying to connect with the code ? If yes how you came to know that phone wont close connection ?

  5. #5
    Registered User
    Join Date
    Aug 2003
    Location
    South Africa
    Posts
    189

    Re: Closing connection?

    Hi

    I have the same problem. When an application uses internet connectivity, the internet connection remains open (Checked In Tools -> Connectivity -> Con Mgr On a Nokia N95) until the app is closed even if you close the connection in the app.

    My only problem with this is, I believe that keeping a connection open uses the phones battery (correct me if I am wrong)

    Steve

  6. #6
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Thumbs up Re: Closing connection?

    Hi,
    As you are opening the connection and your work is complete with that..just in finally block close the same...for the further coming request let the application opens the fresh connection...ok

    check the Google and search the examples..3
    try {
    c = (HttpConnection)Connector.open(url);
    c.setRequestMethod(HttpConnection.GET);
    c.setRequestProperty("IF-Modified-Since",
    "10 Nov 2000 17:29:12 GMT");
    c.setRequestProperty("User-Agent",
    "Profile/MIDP-1.0 Confirguration/CLDC-1.0");
    c.setRequestProperty("Content-Language",
    "en-CA");
    os = c.openOutputStream();

    /**
    String str = "?idnum=182016";
    byte postmsg[] = str.getBytes();
    for(int i=0;i<postmsg.length;i++) {
    os.writeByte(postmsg[i]);
    }
    os.flush();
    */

    is = c.openDataInputStream();
    int ch;
    while ((ch = is.read()) != -1) {
    b.append((char) ch);
    System.out.println((char)ch);
    }
    t = new TextBox("Final Grades",
    b.toString(), 1024, 0);
    } finally {
    if(is!= null) {
    is.close();
    }
    if(os != null) {
    os.close();
    }
    if(c != null) {
    c.close();
    }
    }

    for the details you check the links -
    http://www.ibm.com/developerworks/java/library/wi-jio/
    http://www.java2s.com/Code/Java/J2ME/HttpConnection.htm

    Thanks,
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  7. #7
    Regular Contributor
    Join Date
    Oct 2008
    Posts
    56

    Re: Closing connection?

    of course we close the connection objects in the end ? if thats what you are talking about - your code is almost 1 to 1 of mine.
    so exiting the application should close connection ?
    if there and if block i can write to see if internet connectivity is open for my app (so in this case i close my app) ...

  8. #8
    Nokia Developer Champion
    Join Date
    Nov 2007
    Location
    Rome, Italy
    Posts
    2,406

    Re: Closing connection?

    Hi mikecotic,

    as stated on this related thread:

    http://discussion.forum.nokia.com/fo...d.php?t=138531

    you have not direct control over device data connections, so there's no way, in Java ME, to explicitly ask to close them.

    Pit

  9. #9
    Regular Contributor
    Join Date
    Oct 2008
    Posts
    56

    Re: Closing connection?

    ouch .
    so closing application , would be the only solution ?

Similar Threads

  1. Connection times out after 10 requests...
    By QSIPhone in forum Mobile Java Networking & Messaging & Security
    Replies: 4
    Last Post: 2007-04-09, 17:29
  2. Close HTTp Connection in N6230i
    By cars2004 in forum Mobile Java General
    Replies: 1
    Last Post: 2005-06-24, 10:46
  3. Close HTTp Connection in N6230i
    By cars2004 in forum Mobile Java Networking & Messaging & Security
    Replies: 0
    Last Post: 2005-06-24, 09:29
  4. Closing a Socket Connection
    By maniac_2k in forum Symbian Networking & Messaging (Closed)
    Replies: 4
    Last Post: 2004-08-03, 14:36
  5. Replies: 5
    Last Post: 2003-02-07, 11:25

Posting Permissions

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