是什么原因导致 无法连接到远程服务器


      private string test(string url)
        {
            // url = "http://shop1446828838691.1688.com"
            String ret = "";
            WebClient client = new WebClient();
            try
            {
                Stream stre = client.OpenRead(url);
                System.Net.ServicePointManager.DefaultConnectionLimit = 50;
                StreamReader reader = new StreamReader(stre, Encoding.GetEncoding("gb2312"));
                ret = reader.ReadToEnd();
                reader.Close();
            }
             catch (WebException ex)
                {
                    if (ex.Status == WebExceptionStatus.ConnectFailure)
                    {
                        //无法连接到远程服务器,  
                        MessageBox.Show("WebExceptionStatus.ConnectFailure " + ex.Message);
                    }
                    else if (ex.Status == WebExceptionStatus.Timeout)
                    {
                        //超时  
                        //MessageBox.Show(ex.ToString());
                        MessageBox.Show("WebExceptionStatus.Timeout " + ex.Message);
                    }
                    else if (ex.Status == WebExceptionStatus.ProtocolError)
                    {
                        //文件未找到 
                        MessageBox.Show("WebExceptionStatus.ProtocolError " + ex.Message);
                    }
                }
            return ret;
        } 


你可能感兴趣的:(求助)