This week's giveaway is in the Spring forum.
We're giving away four 3 month subscriptions to Marco Behler Videos and have Marco Behler on-line!
See this thread for details.
Win a 3 month subscription to Marco Behler Videos this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How Can interrupt a HTTP connection ?  RSS feed

 
Ould Nadif
Ranch Hand
Posts: 184
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

So far, I can't interrupt my HTTP connection started from my J2ME application. I have to wait until the connection will have etablished to quit the current process. If my connection lasted 20 seconds I would have to wait 20 seconds.

Could you help me to resolve this problem.

OULD NADIF
 
Ould Nadif
Ranch Hand
Posts: 184
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

There is new.

I created two threads: one to connect to my server and another to close the connection.

Thread1{
conn = httpconnection.open(myURL)
}

If I decided to interrupt ma connection I would lauch the second thread without to wait the result of the connection;
Thread2{
conn = httpconnection.close()
}

Like that I caugth the InterruptedIOException and the probem will be resolved.

I tested with the motorola V525, Siemens SX1 and N-gage:
Results:
It works very gooD with motorola. Et in the other cases it failed.

I don't know why.

OULD NADIF
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!