tags:

views:

130

answers:

2

I want to write a small application that can: 1. monitor URLs requested via a web browser and/or 2. monitor incoming http responses on the local machine

I have been doing some Googling, but I am not finding any clear answers. I am thinking maybe System.Net.Sockets.TCPListener and messing around with it, but I am under the impression that it is either not what I"m looking for or can't handle both things.

I don't need a detailed step by step explanation. Just a small overview would be helpful (if this is even possible) such as (what classes to use, what events to subscribe to, any additional details needed to instantiate necessary objects) I can google the details.

+2  A: 

Why not just extend Fiddler to suit your needs?

Si
A: 

You may want to use a utility like Wireshark (graphical, but not scriptable from C#, AFAIK). Wireshare uses a library called WinPcap, which does the actual monitoring of the TCP streams on the computer. Decoding of the HTTP headers will need to be done in your application (this is what wireshark/tcpdump/windump should be able to do). You will need to use PInvoke to call the WinPcap DLL. You can find library wrappers by performing a web search for "WinPcap PInvoke".

This question sound very similar to the following:

http://stackoverflow.com/questions/137407/is-there-any-way-in-net-to-programmatically-listen-to-http-traffic

EDIT: Also, http://stackoverflow.com/questions/532746/capturing-http-requests may help

Pigrew