本文介绍了听HTTP请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我想要监听来自其他计算机传入的HTTP请求的C#窗体应用程序。

I have a C# form application which I want to have listening for incoming HTTP requests from other computers.

我怎么会去这样做?

推荐答案

对于简单的需求,的类是一个很好的和简单的选择。有链接MSDN页面上的例子。

For simple needs, the HttpListener class is a good and simple choice. There is an example on the linked MSDN page.

如果由于某种原因,你不能使用的HttpListener ,这个过程将是用来听端口的TcpClient (甚至套接字API,如果你需要坚韧不拔的细节),然后实现的。我强烈推荐的HttpListener 在滚动您自己,除非你有特殊要求的的HttpListener 不符合。

If, for some reason, you cannot use HttpListener, the process would be to listen to a port using TcpClient (or even the sockets API if you need the gritty details), and then implement the HTTP Protocol. I highly recommend HttpListener over rolling your own, unless you have specific requirements that HttpListener does not meet.

这篇关于听HTTP请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 20:18