You Are Here:

Community: Developer Discussion Boards

#1 Old How to abort a connection? - 2003-04-02, 21:46

Join Date: Mar 2003
Posts: 26
luemkemann
Offline
Registered User
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
Reply With Quote

#2 Old 2003-10-29, 09:38

Join Date: Oct 2003
Posts: 10
axisperfect
Offline
Registered User
Same problem on the 6610. Has a solution been found?
Reply With Quote

#3 Old 2003-11-12, 13:24

Join Date: May 2003
Posts: 12
fboya
Offline
Registered User
Same problem on Nokia 7650.
Any updates?
Reply With Quote

#4 Old 2003-11-12, 14:52

Join Date: Jun 2003
Posts: 4,325
Location: Cheshire, UK
grahamhughes's Avatar
grahamhughes
Offline
Forum Nokia Champion
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.
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

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

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia