6
我想知道如何去閱讀與HttpWebRequest和HttpWebResponse的持久連接。問題似乎是GetResponseStream()函數在返回之前等待服務器連接關閉。C#HttpWebResponse彗星問題
有沒有其他簡單的方法來讀取彗星連接? 不起作用的示例。
// get the response stream
Stream resStream = response.GetResponseStream();
string tempString = null;
int count = 0;
do
{
// fill our buffer
count = resStream.Read(buf, 0, buf.Length);
// as long as we read something we want to print it
if (count != 0)
{
tempString = Encoding.ASCII.GetString(buf, 0, count);
Debug.Write(tempString);
}
}
while (true); // any more data to read?
你怎麼知道GetResponseStream()等待連接關閉? – feroze 2010-09-19 00:34:51