想获得一个网络上的服务器的时间。
但调试时老提示错误 "Section=ResponseStatusLine"
怎么办?代码如下           HttpWebRequest request = null;
            HttpWebResponse response = null;
            Stream receiveStream = null;
            StreamReader readStream = null;            request = (HttpWebRequest)WebRequest.Create("http://time.nist.gov:13/nist");            Console.WriteLine(request.RequestUri.AbsolutePath);            response = (HttpWebResponse)request.GetResponse();
            receiveStream = response.GetResponseStream();            // Pipes the stream to a higher level stream reader with the required encoding format. 
            readStream = new StreamReader(receiveStream);
            string line = "";
            while (true)
            {
                line = readStream.ReadLine();  //readStream.ReadToEnd();
                if (line == null || line.Equals(""))
                {
                    break;
                }
                string timenow = line;
                MessageBox.Show(timenow);
            }

解决方案 »

  1.   

    在运行于服务器上的dll里写一个return DateTime.Now的方法不就完了
      

  2.   

    ???啥服务器,我自己哪里来的服务器。是网络上别人的服务器!
    你没明白我的意思吧。举例:某授时中心网站对外提供时间校对服务,我现在就想写几行代码,去它的网站获取时间。我写的代码是从这个网址获取时间http://time.nist.gov:13/
    你打开这个网址看看。
      

  3.   

    现在的问题是用IE打开那个网址就能看到数据了,但就是不知在C#里面怎么能接收数据并读出来,用HttpWebRequest方法不行,服务器老拒绝。
    可能得用TCP协议啥的?