Use of HttpListener

前端 未结 2 1329
甜味超标
甜味超标 2021-02-14 17:54

I have the following HTTP listener method, greatly inspired by MSDN\'s example use of the HttpListener class. I\'m fairly new to programming and I\'m not sure where to go from h

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-14 18:17

    you can do something like this :

       public void ListenTraces()
        {
            httpListener.Prefixes.Add(PORT_HOST);
            try
            {
                httpListener.Start();
            }
            catch (HttpListenerException hlex)
            {
                log.Warn("Can't start the agent to listen transaction" + hlex);
                return;
            }
            log.Info("Now ready to receive traces...");
            while (true)
            {
                var context = httpListener.GetContext(); // get te context 
    
                log.Info("New trace connexion incoming");
               Console.WriteLine(context.SomethingYouWant);
            }
        }
    

提交回复
热议问题