How to implement HTTP connection timeout


Posted on 16th Feb 2014 07:03 pm by admin

Hi All,I would like to implement an HTTP connection timeout.

I am working on a application which uses HTTP connection,
but the problem here is that the response from server
is late... I want to create a timeout against HTTP
request such that if response doesn't come within sec
then the connection should get closed.

Please let me know how I can implement this.

Code is like:

HttpConnection connection = null;
connection = (HttpConnection) Connector.open(getURL(), Connector.READ);
int responseCode = connection.getResponseCode();

I am receiving response code almost after 2-3 sec.. and
sometimes 1-2 mins too, which makes my application hang.

I want to create a timeout for such situation, Please let
me know how I can implement.. "connection" variable is
a local variable.

Thanks

No comments posted yet

Your Answer:

Login to answer
93 Like 35 Dislike
Previous forums Next forums
Other forums

Time-based image rotation script
I'm trying to write a PHP script that rotates an image based on what time of day it is. I want the

Problem with HTTP Caching...?
Hi there, im trying to implement caching. But it doesn't always work.
I post it here because ther

chat
hello i'm amir i need a chat source code in asp.net 2.0 without Ajax. anybody can help me?

url- go to webpage
i have an input text field and submit button.

how do i make the url entered into the textfiel

EXplanation help
Hey all,

I am still fairly new to PHP programming and I am trying to put together a page wher

Insert Failing.
Hey,
I am making a Sign up page for a website, but the insert query into the Database does not se

How to give the privillege for triggers?
Hi,

How to give the privillage for triggers to particular user?

Please let me

Upload Code Help
Hi everyone I need some help with a bit of code ive been working with for a while. I am completely s

how to load php class from another domain?
how to load php class from another domain?

Day of week
I am using PHP version 5.0.5
I have a varaible ($DATE (date format yyyy-mm-dd)) that is being inc

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash