我有一个应用程序同时连接到许多网站,并通过http下载大文件。
当我使用TcpView
检查系统时,CLOSE_WAIT
状态下有许多连接。我的代码是这样的:
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
}
catch
{
if (response != null)
response.Close();
}
Stream stream = Response.GetResponseStream();
// read stream until an error happens or we reach end of stream. Then:
if (request != null)
request.Abort();
if (response != null)
response.Close();
为什么我在CLOSE_WAIT
州仍有很多连接?