java HttpConnectionParams.setConnectionTimeout 是什么意思?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13550509/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What does HttpConnectionParams.setConnectionTimeout mean?
提问by Xander
I've got some trouble downloading a webpage's HTML (see this question: Android: Downloading HTML not always working).
我在下载网页的 HTML 时遇到了一些问题(请参阅此问题:Android: Downloading HTML not always working)。
In my code, I use this method:
在我的代码中,我使用这种方法:
HttpConnectionParams.setConnectionTimeout(my_httpParams, 3000);
I'm not really sure what it means. Does this mean that if it takes longer than 3000 millis to download the HTML file (for which I use it), it stops? Or does it mean something else?
我不太确定这意味着什么。这是否意味着如果下载 HTML 文件(我使用它)花费的时间超过 3000 毫秒,它会停止吗?还是有别的意思?
Also, what it the difference between that method and setSoTimeout
?
另外,该方法与setSoTimeout
?
回答by PearsonArtPhoto
It means that if you haven't made a connection in 3000 ms, it will stop trying.
这意味着如果您在 3000 毫秒内没有建立连接,它将停止尝试。
The setSoTimeout()
method is essentially the same thing, but it will wait for more than just the initial connection. So you would be checking each packet to see if it timed out, while the setConnectionTimeout()
method will only time out on the initial connection. See this answerfor more details.
该setSoTimeout()
方法本质上是相同的,但它等待的不仅仅是初始连接。因此,您将检查每个数据包是否超时,而该setConnectionTimeout()
方法只会在初始连接时超时。有关更多详细信息,请参阅此答案。
回答by lory105
For more details see this answer that explains difference between connection timeoutand socket timeout:
有关更多详细信息,请参阅此答案,该答案解释了连接超时和套接字超时之间的区别: