×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Nokia Developer Champion
    Join Date
    Apr 2007
    Posts
    2,708

    Post How to block ongoing network Connection ?

    Hi,
    I have made an application with a custom made connection class. This class actually doe nothing more than connecting to a particular url through http. The only added functionality is a priority-based vector which stores all the requests for a http connection and sends them according to their priority.
    Sometimes it happens I am sending a request with a low priority when all of a sudden a new higher priority request is added to my vector.
    is there a way to stop an already ongoing connection so that the new higher priority one can be processed right away ?
    I tried with resetting the used connection, and also closing my input and output streams :

    Code:
     private InputStream in = null;
     private OutputStream out = null;
    
    conn = (HttpConnection)Connector.open(request.getUrl(), Connector.READ_WRITE, true);
    
    if (in != null)
    {
        try
        {
            in.close();
        }
        catch (IOException e)
        {
             System.err.print(e.toString());
        }
    }
    if (out != null)
    {
         try
         {
             out.close();
         }
         catch (IOException e)
         {
             System.err.print(e.toString());
         }
    }
    closeConnection();
    and

    Code:
    public void closeConnection()
    {
       if (conn != null)
       {
           try
           {
               conn.close();
           }
           catch (IOException e)
           {
               System.out.println("Probleem met closen Connectie : " + e.toString());
           }
       }
       System.gc();
    }

  2. #2
    Regular Contributor
    Join Date
    Jun 2008
    Location
    Tel-Aviv,Israel
    Posts
    100

    Thumbs up Re: How to block ongoing network Connection ?

    Hi Tiger79

    A simple solution is to work with Threads.
    Create an Index Number for each request.
    lets say a low level connection is established,
    sudden, a new High Priority is ready to initiate,
    if a high priority request has inititated,kill the preivous Object thread.


    Or Let your server decide which Connection to work with or letting go by sending the Priority as REQUEST HEADER.

    Bare in mind, if those are long term requests, expect loss information over IT in ur server..
    Y

Similar Threads

  1. Nokia s60 SDK v2.0 - emulator network connection problem
    By eikka4 in forum Symbian Tools & SDKs
    Replies: 14
    Last Post: 2007-03-08, 06:53
  2. Network connection through data (serial) cable?
    By maffeis in forum Mobile Java Networking & Messaging & Security
    Replies: 0
    Last Post: 2003-08-11, 07:52
  3. access internet through pc's network connection
    By yinjialiang in forum PC Suite API and PC Connectivity SDK
    Replies: 0
    Last Post: 2003-07-30, 05:48
  4. Using RGenericAgent to initiate Network connection?
    By mmalo in forum Symbian Networking & Messaging (Closed)
    Replies: 2
    Last Post: 2003-02-07, 16:39
  5. Network connection
    By donlexx in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2002-05-16, 11:41

Posting Permissions

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