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

Drawing Images in classes
I'm quite new to Object Oriented PHP. What I'm trying to do is draw some images but also have other

Using CSS to format MySQL query
Hi,

If i want to have a news page on my site, which displays all records of a table in descen

Getting PHP to ammended the selected in option field
Hey Guys

thanks for everyones help so far. This site and its users are oozing awesomness.

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

database design
Hi,

I got a page which allow candidate to type in their previous working experience,
I let

unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_
Can anyone view my code and tell me why im getting the error:
Parse error: syntax error, unexpect

Making multiple rows with one query
I have a table called efed_handler_characters with two fields handler_id and bio_id. What query 2 is

Change snippet to use CURDATE
I am using time() in the snippet below, I would like to use CURDATE() and have the database setup fo

Multipe Dynamic Controls & AutoPostback Issue
I currently have a need to create many dynamic controls (Example Textboxes) that need to do a PostBa

Dealing with code in db query
I am dealing with C code and I need to make sure it is encoded some how to ensure its integrity and

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