事例实现一个网页的下载
namespace ConsoleApplication12
{
class Program
{
private const int readBufferSize = 1024;
static void Main(string[] args)
{
if (args.Length != 1)
{
Console.WriteLine("参数错误");
}
string ip = args[0];
//创建任务
Task<String> task = RequestHttpAsync(ip);
//阻塞线程
Console.WriteLine(task.Result);
Console.ReadKey();
}
private static async Task<String> RequestHttpAsync(string ip)
{
using (var client = new TcpClient())
{
try
{
//连接指定的地址 默认端口80
await clie