WebRequest.GetResponse 第三次就會顯示超時是為什麼?

lertulo 2009-06-25 02:49:05

try
{
for (int i = 0; i < 5; i++)
{
WebRequest rq = WebRequest.Create("http://10.2.1.8/it/winrar.exe");
WebResponse rp = rq.GetResponse();
}
}
catch (Exception Err)
{
String a = Err.Message;
MessageBox.Show(Err.Message);
}
...全文
87 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
lertulo 2009-06-25
  • 打赏
  • 举报
回复


You have reached the connection limit on the client ( 2 conns per http/1.1 server, 4 connections per http/1.0 server, or custom limit set on the ServicePoint), and no connection is free to send a request to the server. In other words, you might have 2 requests outstanding (eg: to a 1.1 server) which are taking more than 2 minutes to complete, and then issue another GetResponse() to the same server. The last getresponse() might time out.

參考
http://blogs.msdn.com/feroze_daud/archive/2004/01/21/61400.aspx

看到了,呵呵,我以為每次會 重新實例化一個類,忘了考慮服務器了。

feiyun0112 2009-06-25
  • 打赏
  • 举报
回复
WebResponse 用完关掉

*****************************************************************************
欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码)

http://feiyun0112.cnblogs.com/

110,537

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧