異步http listener 完全并發(fā)處理懲罰http懇求的小例子
更新時間:2013年05月24日 15:28:40 作者:
異步http listener 完全并發(fā)處理懲罰http懇求的小例子,需要的朋友可以參考一下
復(fù)制代碼 代碼如下:
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 { }
}
}
}
相關(guān)文章
C語言中回調(diào)函數(shù)的含義與使用場景詳解(2)
這篇文章主要為大家詳細(xì)介紹了C語言中回調(diào)函數(shù)的含義與使用場景,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下,希望能夠給你帶來幫助2022-03-03
C++基于reactor的服務(wù)器百萬并發(fā)實現(xiàn)與講解
這篇文章主要介紹了C++基于reactor的服務(wù)器百萬并發(fā)實現(xiàn)與講解,本文通過實例圖文相結(jié)合給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2022-07-07

