getting the local port as netstat in C# + small doubt on network connection
-
Hi All This post got actually 2 questions but related each other. I hope you can help me even just solving one of the 2. In Windows I usually call NETSTAT to have information regarding the status of my network connections. I am interested in getting the data below produced by Netstat using C#. *Local Address *The state of the connection. Active Connections Proto Local Address Foreign Address State TCP ITA-2317A:3377 server1.mylan.co.uk:50506 FIN_WAIT_2 TCP ITA-2317A:3378 server1.mylan.co.uk:50507 FIN_WAIT_2 I am interested in catching the FIN_WAIT_2 state that sometimes is causing me some problems. My C# application sometimes leaves the network connection in this state..do you know some possible workaround? I am using TcpClient class and I use Close() method..after I do this what check can I do to make sure that my connection is not in the FIN_WAIT_2 state?
-
Hi All This post got actually 2 questions but related each other. I hope you can help me even just solving one of the 2. In Windows I usually call NETSTAT to have information regarding the status of my network connections. I am interested in getting the data below produced by Netstat using C#. *Local Address *The state of the connection. Active Connections Proto Local Address Foreign Address State TCP ITA-2317A:3377 server1.mylan.co.uk:50506 FIN_WAIT_2 TCP ITA-2317A:3378 server1.mylan.co.uk:50507 FIN_WAIT_2 I am interested in catching the FIN_WAIT_2 state that sometimes is causing me some problems. My C# application sometimes leaves the network connection in this state..do you know some possible workaround? I am using TcpClient class and I use Close() method..after I do this what check can I do to make sure that my connection is not in the FIN_WAIT_2 state?
-
This probably can help you: http://support.microsoft.com/kb/821625[^]
Thanks! I am testing this right now..I have a small doubt bit trivial. I use embed the NetworkStream in a StreamReader like this
NetworkStream aStream = _client.GetStream();
StreamReader reader = new StreamReader(aStream);calling
reader.Close()
does it safely close also theNetworkStream
underlying or do I have to keep a reference to the NetworkStream and close it explicitly? -
Thanks! I am testing this right now..I have a small doubt bit trivial. I use embed the NetworkStream in a StreamReader like this
NetworkStream aStream = _client.GetStream();
StreamReader reader = new StreamReader(aStream);calling
reader.Close()
does it safely close also theNetworkStream
underlying or do I have to keep a reference to the NetworkStream and close it explicitly?