Creating a web server that responds to every incoming request with a simple message
I'd like to create a web server that responds to every incoming request with a simple开发者_C百科 "Hello" message in C#.
How do I do that?
How much of it do you need to do from scratch? It's pretty simple to do this if you're allowed to use HttpListener
.
Otherwise, you might want to look at TcpListener
- accept a socket connection, read data from it, and write a response. Admittedly it's somewhat easier if you can answer every request with "Hello" as you don't need to really parse it...
You can read an article on CodeProject
http://www.codeproject.com/KB/IP/mywebserver.aspx
There is also a project on codeplex
http://webserver.codeplex.com/
You will need Sockets, Multithreading and the RFC http://www.faqs.org/rfcs/rfc2616.html
精彩评论