• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to set Timeout in HttpConnection

 
Sasi Kumar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • 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
 
Rashid Mayes
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • 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).
 
Don Solomon
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic