源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

异步http listener 完全并发处理惩罚http恳求的小例子

  • 时间:2022-01-24 06:13 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:异步http listener 完全并发处理惩罚http恳求的小例子
[u]复制代码[/u] 代码如下:
using System;  using System.Collections.Generic;  using System.Linq;  using System.Text;  using System.Net;  using System.Net.Sockets;  using DevSDK.Net.Sockets;  using System.IO;  namespace ConsoleApplication1  {      class Program      {          static HttpListener sSocket = null;          static void Main(string[] args)          {              sSocket = new HttpListener();              sSocket.Prefixes.Add("http://127.0.0.1:8080/");              sSocket.Start();              sSocket.BeginGetContext(new AsyncCallback(GetContextCallBack), sSocket);              Console.Read();                     }          static void GetContextCallBack(IAsyncResult ar)          {              try              {                  sSocket = ar.AsyncState as HttpListener;                  HttpListenerContext context = sSocket.EndGetContext(ar);     sSocket.BeginGetContext(new AsyncCallback(GetContextCallBack), sSocket);                  Console.WriteLine(context.Request.Url.PathAndQuery);              }              catch { }          }      }  }
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部