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
Did you know?Explore Trending and Topic pages for more stories like this.
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

Cache PHP Objects/Classes?
Does anyone have ideas about caching PHP objects using something like: http://memcached.org/

Problem with "dynamic" index page
Hi. I have one question. In my index.php page I have this kind of code:
Code: // listaa sivut

start new row of pictures
on my site www.budstreasureauctions.com there is a featured auctions box that users will pay to get

noob question
i traying to do a php form with auto replay for both(me and the user who send me a mail),

a u

How to read CSS message data
Hi,
I have a requirement here. When working as a Dev angel for multiple customers its really di

Odd or Even
Inside of a while loop I need to echo several rows of info...easy enough.

In the loop (for th

Date Question
I'm using the TIMESTAMP() function within mysql to set the date/time for certain events. However, ho

some questions
Hello,

I am looking for the answers for following questions:

1) Does PHP support overl

Include a php
Hello,

I'm trying to include a function that shows the recent searches.
Example I have <

Error in write byte array into document in SM58
Hi Gurus,

Getting the following error status in Transactional RFC (SM58) ..... *Error i

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