简体   繁体   中英

Using Http Handlers to listen to port 80

I need to write an Http Handler to listen to port 80.

What should be the approach? Like should I use raw sockets to listen to port 80 within Http Handler or is there a better way to do?

I went through some tutorials as the one specified below..

http://msdn.microsoft.com/en-us/library/ms228090.aspx

But couldn't make much out of it. Any idea will appreciated.

Thanks

An HTTP handler is just a handler that gets called by an application host, such as Internet Information Services (IIS). IIS can listen on port 80 and invoke an HTTP handler, but it is not the HTTP Handler's job to listen on a port, or even care which port the application host is listening on.

What should be the approach? Like should I use raw sockets to listen to port 80 within Http Handler or is there a better way to do?

Just use IIS, or IIS Express . Create an HTTP handler, and let IIS listen on port 80.

OK. What you are looking at is a way to make a handler in IIS. If IIS isn't desired, consider using HttpListener to hook the HttpPipeline from any app.

Socket is a very flexible way to create HTTP handlers but you have to do more with sockets. if classes like HttpListener fullfill your requirement always go for them. unless it will be something like re-inventing the wheel.

This is a working code sample which shows how to use Sockets to listen TCP requests. http://kaninotes.blogspot.com/2012/02/how-to-implement-threaded-server-socket.html

But go for HttpListener if you deal with http stuff.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM