I have asp.net website. When I create a test page with a Thread.Sleep before page load. There is forms authentication for login. After one hour of wait the page automatically logs out. So I want to see what is the reason for this logout. I am planning to capture all the HttpConnection Communications using C# code. I want to see the communication close reason only. I am running the website in local machine using Visual Studio 2005.
Can you please share code for achieving this functionality?
Note: I understand this can be achieved using tools like tcpDump. But currently I am trying to develop a code for this functionality alone – to see the reason of connection close/logout.
UPDATE:
I have the following code. But how do I achieve my task - how to find the reason for all connection close/logout. Please help me since I am totally new to socket programming.
protected void Page_Load(object sender, EventArgs e)
{
IPHostEntry host;
string localIPAddress = "?";
host = Dns.GetHostEntry(Dns.GetHostName());
foreach (IPAddress ip in host.AddressList)
{
if (ip.AddressFamily == AddressFamily.InterNetwork)
{
localIPAddress = ip.ToString();
}
}
System.Net.Sockets.Socket mySocket = new System.Net.Sockets.Socket(System.Net.Sockets.AddressFamily.InterNetwork, System.Net.Sockets.SocketType.Raw, System.Net.Sockets.ProtocolType.IP);
mySocket.Bind(new System.Net.IPEndPoint(System.Net.IPAddress.Parse(localIPAddress), 0));
mySocket.SetSocketOption(System.Net.Sockets.SocketOptionLevel.IP, System.Net.Sockets.SocketOptionName.HeaderIncluded, 1);
byte[] inBytes = new byte[] { 1, 0, 0, 0 };
byte[] outBytes = new byte[] { 0, 0, 0, 0 };
mySocket.IOControl(System.Net.Sockets.IOControlCode.ReceiveAll, inBytes, outBytes);
}