简体   繁体   English

Android连接超时

[英]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? HttpURLConnection类中,有两种设置超时的方法:一种是setConnectTimeout(t1) ,另一种是setReadTimeout(t2)和t2之间的关系是什么? Should t1>t2 ? t1>t2应该吗?

setConnectTimeout() is a the timeout of the connection, meaning how long it takes to connect to the server setConnectTimeout()是连接超时,表示连接到服务器需要多长时间

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 setReadTimeout()是读取超时,表示从服务器读取需要多长时间,如果花费的时间长于超时,则会使读取超时

In a way they don't have anything to do 在某种程度上,他们无事可做

setConnectTimeout(milliseconds) :Sets the maximum time in milliseconds to wait while connecting. setConnectTimeout(milliseconds) :设置连接时等待的最长时间(以毫秒为单位) setReadTimeout(milliseconds) :Sets the maximum time to wait for an input stream read to complete before giving up . setReadTimeout(milliseconds) :设置放弃输入之前等待输入流读取完成的最长时间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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