• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# HttpListener类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中HttpListener的典型用法代码示例。如果您正苦于以下问题:C# HttpListener类的具体用法?C# HttpListener怎么用?C# HttpListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



HttpListener类属于命名空间,在下文中一共展示了HttpListener类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: AddPrefix

 public static void AddPrefix(string uriPrefix, HttpListener httpListener)
 {
     lock (((ICollection) _ipToEndpoints).SyncRoot)
     {
         addPrefix (uriPrefix, httpListener);
     }
 }
开发者ID:richardfeng,项目名称:UnitySocketIO-WebSocketSharp,代码行数:7,代码来源:EndPointManager.cs


示例2: AddPrefix

 public static void AddPrefix(string prefix, HttpListener listener)
 {
     lock (_ipToEndpoints)
     {
         AddPrefixInternal(prefix, listener);
     }
 }
开发者ID:unosquare,项目名称:embedio,代码行数:7,代码来源:EndPointManager.cs


示例3: getEndPointListener

    private static EndPointListener getEndPointListener (
      IPAddress address, int port, HttpListener httpListener, bool secure)
    {
      Dictionary<int, EndPointListener> endpoints = null;
      if (_ipToEndpoints.ContainsKey (address)) {
        endpoints = _ipToEndpoints [address];
      }
      else {
        endpoints = new Dictionary<int, EndPointListener> ();
        _ipToEndpoints [address] = endpoints;
      }

      EndPointListener epListener = null;
      if (endpoints.ContainsKey (port)) {
        epListener = endpoints [port];
      }
      else {
        epListener = new EndPointListener (
          address,
          port,
          secure,
          httpListener.CertificateFolderPath,
          httpListener.DefaultCertificate);

        endpoints [port] = epListener;
      }

      return epListener;
    }
开发者ID:JChan106,项目名称:HACKPOLY16,代码行数:29,代码来源:EndPointManager.cs


示例4: Awake

 void Awake()
 {
     listener = new HttpListener();
     listener.Prefixes.Add("http://*:7663/");
     listener.Start();
     listener.BeginGetContext(new AsyncCallback(ListenerCallback), listener);
 }
开发者ID:rcahoon,项目名称:AerialAssistSim,代码行数:7,代码来源:Vision.cs


示例5: StartListener

 static void StartListener()
 {
     listener = new HttpListener();
     listener.Prefixes.Add("http://localhost:57789/");
     listener.Start();
     listener.BeginGetContext(ListenerCallback, listener);
 }
开发者ID:ryanrdl,项目名称:docs.particular.net,代码行数:7,代码来源:Program.cs


示例6: ListenThread

    private void ListenThread()
    {
        try
        {
            listener = new HttpListener();

            foreach (string prefix in prefixes)
            {
                listener.Prefixes.Add(prefix);
            }

            listener.Start();

            while (true)
            {
                HttpListenerContext context = listener.GetContext();

                Debug.LogFormat("Recieved request from {0}.", context.Request.RemoteEndPoint.ToString());

                context.Response.StatusCode = 200;

                lock (waitingContexts)
                {
                    waitingContexts.AddLast(context);
                }
            }
        }
        catch(Exception e)
        {
            Debug.LogErrorFormat("Web server error at {0}.", e.Source);
            Debug.LogError(e.Message, this);
        }
    }
开发者ID:bonbombs,项目名称:CrimeTimeUNET,代码行数:33,代码来源:WebServer.cs


示例7: EndPointListener

        private ArrayList _unhandled; // List<ListenerPrefix> unhandled; host = '*'

        #endregion Fields

        #region Constructors

        public EndPointListener(HttpListener listener, IPAddress addr, int port, bool secure)
        {
            Listener = listener;

            if (secure)
            {
            #if SSL
                this.secure = secure;
                cert = listener.LoadCertificateAndKey (addr, port);
            #else
                throw new Exception("SSL is not supported");
            #endif
            }

            _endpoint = new IPEndPoint(addr, port);
            _sock = new Socket(addr.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
            _sock.Bind(_endpoint);
            _sock.Listen(500);
            var args = new SocketAsyncEventArgs {UserToken = this};
            args.Completed += OnAccept;
            Socket dummy = null;
            Accept(_sock, args, ref dummy);
            _prefixes = new Hashtable();
            _unregistered = new Dictionary<HttpConnection, HttpConnection>();
        }
开发者ID:unosquare,项目名称:embedio,代码行数:31,代码来源:EndPointListener.cs


示例8: Main

    static void Main()
    {
        Console.Title = "Samples.CustomChecks.3rdPartySystem";
        Console.WriteLine("Press enter key to toggle the server to return a error or success");
        Console.WriteLine("Press any key to exit");

        using (listener = new HttpListener())
        {
            listener.Prefixes.Add("http://localhost:57789/");
            listener.Start();
            listener.BeginGetContext(ListenerCallback, listener);

            while (true)
            {
                ConsoleKeyInfo key = Console.ReadKey();
                Console.WriteLine();

                if (key.Key != ConsoleKey.Enter)
                {
                    return;
                }
                listener.Close();
                if (isReturningOk)
                {
                    Console.WriteLine("\r\nCurrently returning success");
                }
                else
                {
                    Console.WriteLine("\r\nCurrently returning error");
                }
                isReturningOk = !isReturningOk;
            }
        }
    }
开发者ID:odelljl,项目名称:docs.particular.net,代码行数:34,代码来源:Program.cs


示例9: AddPrefix

 public static void AddPrefix(ILogger logger, string prefix, HttpListener listener)
 {
     lock (ip_to_endpoints)
     {
         AddPrefixInternal(logger, prefix, listener);
     }
 }
开发者ID:softworkz,项目名称:SocketHttpListener,代码行数:7,代码来源:EndPointManager.cs


示例10: AddListener

        public static void AddListener(HttpListener listener)
        {
            ArrayList added = new ArrayList();

            try
            {
                lock (ip_to_endpoints)
                {
                    foreach (string prefix in listener.Prefixes)
                    {
                        AddPrefixInternal(prefix, listener);

                        added.Add(prefix);
                    }
                }
            }
            catch
            {
                foreach (string prefix in added)
                {
                    RemovePrefix(prefix, listener);
                }

                throw;
            }
        }
开发者ID:jamesaxl,项目名称:reactor,代码行数:26,代码来源:EndPointManager.cs


示例11: FixtureSetup

 public void FixtureSetup()
 {
     _listener = new HttpListener(_uri.OriginalString);
     _listener.Start();
     _server = new Tracker();
     _server.RegisterListener(_listener);
     _listener.Start();
 }
开发者ID:mrscylla,项目名称:octotorrent,代码行数:8,代码来源:TrackerTests.cs


示例12: Server

        public Server()
        {
            this.httpListener = new HttpListener();

            this.httpListener.Prefixes.Add("http://localhost:8080/");
            this.httpListener.Prefixes.Add("http://127.0.0.1:8080/");
            this.httpListener.Prefixes.Add("http://test.localhost:8080/");
        }
开发者ID:MathieuMorrissette,项目名称:Simple-HTTP-Server,代码行数:8,代码来源:Server.cs


示例13: Listener

	public Listener ()
	{
		EndPoints = new List<IPEndPoint> ();

		listener = new HttpListener ();
		listener.Prefixes.Add (KeepAliveTest.URL);
		listener.Start ();
		listener.BeginGetContext (Handle, null);
	}
开发者ID:mono,项目名称:gert,代码行数:9,代码来源:test.cs


示例14: Configure

  public void Configure(string[] prefixes, string vdir, string pdir)
  {
    _virtualDir = vdir;
    _physicalDir = pdir;
    _listener = new HttpListener();

    foreach (string prefix in prefixes)
      _listener.Prefixes.Add(prefix);
  }
开发者ID:wbrussell,项目名称:xmlrpcnet,代码行数:9,代码来源:HttpListenerWrapper.cs


示例15: WebAppServer

 /// <summary>
 /// Create an instance of <see cref="WebAppServer"/>.
 /// </summary>
 /// <param name="urlReservation">
 /// The URL reservation to listen on. This string is similar to a URL, but the
 /// hostname may be a strong wildcard ('+') or a weak wildcard ('*'). E.g. "http://+:8080/".
 /// </param>
 public WebAppServer(string urlReservation)
 {
     _urlRegex = new Regex("^" + urlReservation.Replace("*", ".*?").Replace("+", ".*?"), RegexOptions.IgnoreCase);
     _listener = new HttpListener();
     _listener.Prefixes.Add(urlReservation);
     _disconnectHandler = new DisconnectHandler(_listener);
     var uri = new Uri(urlReservation.Replace("*", "localhost").Replace("+", "localhost"));
     _webAppConfiguration = new WebAppConfiguration(uri);
     StaticFiles = new StaticFileSpecCollection();
 }
开发者ID:jkells,项目名称:WebAppHost,代码行数:17,代码来源:WebAppServer.cs


示例16: RemoveListener

 public static void RemoveListener(ILogger logger, HttpListener listener)
 {
     lock (ip_to_endpoints)
     {
         foreach (string prefix in listener.Prefixes)
         {
             RemovePrefixInternal(logger, prefix, listener);
         }
     }
 }
开发者ID:softworkz,项目名称:SocketHttpListener,代码行数:10,代码来源:EndPointManager.cs


示例17: CreateListener

        public HttpListener CreateListener(List<string> addresses)
        {
            var listener = new HttpListener();

            addresses.ForEach(a => listener.Prefixes.Add(a));

            listener.Start();

            return listener;
        }
开发者ID:ihenehan,项目名称:Behavior,代码行数:10,代码来源:Server.cs


示例18: Server

 public Server(string prefix)
 {
     if (!HttpListener.IsSupported)
     {
         Console.WriteLine("server is not supported");
     }
     listener = new HttpListener();
     listener.Prefixes.Add(prefix);
     resourceLocator = new HttpResourceLocator();
 }
开发者ID:jordanbang,项目名称:MusicDiff-Windows,代码行数:10,代码来源:Server.cs


示例19: NetEventHandler

        public NetEventHandler()
        {
            BaseUrl = Net.GetUrl(Net.GetIp(IPType.All), Net.FindPort(), "").ToString();
            ServicePointManager.DefaultConnectionLimit = 100;
            _httpListener = new HttpListener();
            _httpListener.Prefixes.Add(BaseUrl);

            _httpListener.Start();
            ThreadPool.QueueUserWorkItem(Listen);
        }
开发者ID:madebysoren,项目名称:NooSphere,代码行数:10,代码来源:NetEventHandler.cs


示例20: ListenerScope

		public ListenerScope (Action<HttpListenerContext> processor)
		{
			this.processor = processor;

			this.listener = new HttpListener ();
			this.listener.Prefixes.Add ("http://*:8001/");
			this.listener.AuthenticationSchemes = AuthenticationSchemes.Anonymous;
			this.listener.Start ();

			this.listener.BeginGetContext (this.RequestHandler, null);
		}
开发者ID:mono,项目名称:gert,代码行数:11,代码来源:test.cs



注:本文中的HttpListener类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# HttpListenerContext类代码示例发布时间:2022-05-24
下一篇:
C# HttpHelper类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap