• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

How to set Timeout in HttpConnection

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am using HttpConnection to post the data to server ,In case the server is not running ,sometimes the application hangs,so i need to set timeout for this problem or anybody have a right solution for this?

Sasi Kumar
 
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not aware of a way to do this directly from a standard MIDP device. I believe their is a way if you are using a BlackBerry. That said, you can achieve a similar result and prevent your application from hanging by using threads.

Perform your IO related operations in one thread, using a the main (UI) thread or another thread to monitor the progress of your IO related thread. If your timeout interval elapses you can then alert the user, set a flag to indicate that the IO thread should not continue (i.e. if open succeeds after, do not read, etc).
 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
honestly, i haven't used this http stuff for 10 years but...

i believe your URL parameter for HttpConnection has a URLConnection and an associated timeout specification. give it a try. just a wild stab in the dark.
 
I’m tired of walking, and will rest for a minute and grow some wheels. This is the promise of this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic