BlackBerry Forums Support Community
              

Closed Thread
 
LinkBack Thread Tools
Old 03-06-2007, 06:12 PM   #1 (permalink)
New Member
 
Join Date: Mar 2007
Model: 8700
Posts: 1
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default httpconnection timeout semantics

Please Login to Remove!

When I set the timeout on an HttpConnection, as in

Code:
HttpConnection conn = (HttpConnection)Connector.open(myURL + ";ConnectionTimeout=120000;deviceside=false");
is this timeout a limit on
(a) the total time a blocking operation can take or
(b) the amount of time a blocking operation can go without receiving data over the connection or
(c) something else

For example, suppose I have the following code:

Code:
HttpConnection conn = (HttpConnection)Connector.open(myURL + ";ConnectionTimeout=120000;deviceside=false");
int rc = conn.getResponseCode();
if (rc != HttpConnection.HTTP_OK) {
    // Handle failure response from server
}
InputStream is = _connection.openInputStream();
int len = (int)_connection.getLength();
if (len > -1) {
    byte[] data = new byte[len];
    is.read(data);
}
Is it possible for the read() call to take more than 2 minutes? For example, suppose there is no signal for 1:59, then the client receives some data, then there's no signal for another 1:59, etc. Is this possible? Or is the 2 min a hard limit on the duration of the read() call?

Thanks in advance...
Offline  
Old 03-13-2007, 09:08 AM   #2 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Oct 2006
Model: 7103
Carrier: Verizon
Posts: 259
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

bric,
The timeout signals to the thread managing the connection how long to wait before throwing an InterruptedIOException signifying a timeout. Also, in a quirk of java's connection framework, this thread will hold at getLength and throw from there, not read or open, as one might expect.
Offline  




Copyright 2004-2016 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.