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

insert quotes
Hi,

I have an output like this:
Code: john,18,Cancer
How can I change this to
Code:

ereg_replace issue
hi there people

i have this code happening with regards to my wamp server. is this something

HTML Email rec'd as Source Code
The code does create and send the email successfully. However, the message shows as html code and n

php slowing my site?
Hi all,

I think that one of the reasons that my site doesn't work fast is that the code is ve

FTP Programs
Here is a list of commonly suggested FTP Programs to use:

FileZilla
SmartFTP
CuteFTP

Inserting multiple records from single form
I've found a number of threads that deal with this issue, but I'm new to php and coding language so

getting rid of quotes in strings
sick of trying to deal with them in multiple ways (entering in and taking from database, echoing, ec

re calling a function without including file
Hi,
i am new to programming in php, i was just checking the wordpress code and found out in the w

Encrypt php code?
Is it possible to encrypt php code in files,
so that it displays a load of unreadable characters

dynamic table with forms
I have a table that is populated with mysql data and in teh first column there is a raido button tha

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