简体   繁体   中英

Android connection timeouts

In HttpURLConnection class there are two methods foe setting time outs.One is setConnectTimeout(t1) and other is setReadTimeout(t2) .What is the relationship between t1 and t2? Should t1>t2 ?

setConnectTimeout() is a the timeout of the connection, meaning how long it takes to connect to the server

setReadTimeout() is a timeout for reading, meaning how long it takes to read from server, and if it takes longer than that it will timeout the read

In a way they don't have anything to do

setConnectTimeout(milliseconds) :Sets the maximum time in milliseconds to wait while connecting. setReadTimeout(milliseconds) :Sets the maximum time to wait for an input stream read to complete before giving up .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM