zoukankan      html  css  js  c++  java
  • TCP编程(3): WebRequest, WebResponse

    /*--===------------------------------------------===---
    WebRequest, WebResponse

                许明会    23:51:45 2007年12月9日
    --===------------------------------------------===---
    */
    using System;
    using System.Net;
    using System.Text;
    using System.IO;

    namespace xumh
    {
        
    public class runMyApp
        {
            
    static void Main()
            {
                
    string strUriBaidu = @"http://www.baidu.com";
                WebRequest req 
    = WebRequest.Create(strUriBaidu);
                WebResponse res 
    = req.GetResponse();
                Stream srm 
    = res.GetResponseStream();
                System.Text.Encoding ec 
    = Encoding.GetEncoding(936);
                StreamReader sr 
    = new StreamReader(srm,ec);
                System.Text.StringBuilder sb 
    = 
                    
    new System.Text.StringBuilder();

                
    char[] buff = new char[256];
                
    int nCount = sr.Read(buff,0,256);
                
    while(nCount>0)
                {
                    sb.Append(
    new string(buff,0,nCount));
                    nCount 
    = sr.Read(buff,0,256);
                }
                Console.WriteLine(sb.ToString());
                
    //

            }
        };
    }
  • 相关阅读:
    影响STA的因素-OCV
    FPGA的可靠性分析
    DFT
    Verilog 延时模型
    收缩数据库日志
    iis设置局域网访问,Context.Request.Url.Authority老是取出为localhost问题
    vs2012 后期生成事件命令报错 9009
    MIME配置
    sql 字符串拼接 =>for xml()
    js 切换embed的src值
  • 原文地址:https://www.cnblogs.com/flaaash/p/988747.html
Copyright © 2011-2022 走看看