×

Discussion Board

Results 1 to 4 of 4

Hybrid View

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    26

    How to abort a connection?

    I'm writing a program that connects to a server and sends some data. This happens in a thread, which is started by a Form, which in turn has a Cancel button. I would like the connection (attempt) to be cancelled when the user presses Cancel.
    So I've tried several things:Setting the worker thread to null, closing the connection, setting the connection to null, closing the input stream or output stream (all are members of the Form, the thread is an inner class of the Form). This works ok in the MMAPI emulator (which I have to use because I'm also using MMAPI functions), but at the second connection (after having cancelled one before) the phone just hangs so badly, I can't even close the Midelt anymore and have to turn it off. I'm testing with a Nokia 3650.
    Which is the recommended way to abort a connection?

    Thanks
    Dennis

  2. #2
    Registered User
    Join Date
    Oct 2003
    Posts
    10
    Same problem on the 6610. Has a solution been found?

  3. #3
    Registered User
    Join Date
    May 2003
    Posts
    12
    Same problem on Nokia 7650.
    Any updates?

  4. #4
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395
    If my understanding is correct, it is not possible to abort a connection (I'll be gladly proved wrong!!)

    Setting a reference to a Thread to null has no effect, as the VM keeps a reference to live threads. Setting a reference to the connection to null doesn't work either, because the object has a reference to itself while it's executing code ("this").

    Disconnection occurs when the connection is close and all streams openned against that connection have been closed. But only of the connection is actually connected... at the point when you are trying to cancel, it is probably in the process of connecting (so, not connected yet).

    I think that the connection object holds a lock on its own class while connecting... if this is so, then attempting another connection will block until the first completes or fails.

    Graham.

Posting Permissions

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