I am trying to get more information about what is going on when I connect to a website at a lower level than what HttpWebRequest and HttpWebResponse gives me. I am using C#.
I would like to be able to see information about the dns lookup and the time it took to establish a connection (if a new connection was established). HttpWebRequest and HttpWebResponse work at a higher level than this and I want to ask if there is a way of getting the underlying TcpClient object (or whatever low level object they use).
If it is not possible, then is there a way to grab and manipulate a list of the connections that .net is maintaining without getting it through HttpWebRequest or HttpWebResponse?
I can't change the application I am working on to use TcpClient because it would be too time consuming to implement all the http stuff reliably.
The best that I can get you is to create an app.config file with the following information:
<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
<system.diagnostics>
<trace autoflush="true" />
<sources>
<source name="System.Net" maxdatasize="1024">
<listeners>
<add name="MyTraceFile"/>
</listeners>
</source>
<source name="System.Net.Sockets" maxdatasize="1024">
<listeners>
<add name="MyTraceFile"/>
</listeners>
</source>
</sources>
<sharedListeners>
<add
name="MyTraceFile"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="System.Net.trace.log"
/>
</sharedListeners>
<switches>
<add name="System.Net" value="Verbose" />
<add name="System.Net.Sockets" value="Verbose" />
</switches>
</system.diagnostics>
</configuration>
This will enable tracing and will kick out a log file named "System.Net.trace.log" in your app folder. You aren't going to get all of the information that you're looking for and its not easily consumable while the app is running but at least you don't need to have a third-party program running. Its not documented too much but there's some information out there at least.
Use Wireshark, it's the best way to find out all that stuff.
If not Wireshark, then use Fiddler.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With