3 namespace System.Net.NetworkInformation {
6 using System.Net.Sockets;
7 using System.Security.Permissions;
9 using System.Runtime.InteropServices;
10 using System.Collections;
11 using System.ComponentModel;
12 using System.Threading;
18 /// Represents an active Tcp connection.</summary>
19 internal class SystemTcpConnectionInformation:TcpConnectionInformation {
20 IPEndPoint localEndPoint;
21 IPEndPoint remoteEndPoint;
24 internal SystemTcpConnectionInformation(MibTcpRow row) {
27 //port is returned in Big-Endian - most significant bit on left
28 //unfortunately, its done at the word level and not the dword level.
30 int localPort = row.localPort1<<8|row.localPort2;
31 int remotePort = ((state == TcpState.Listen)?0:row.remotePort1<<8|row.remotePort2);
33 localEndPoint = new IPEndPoint(row.localAddr,(int)localPort);
34 remoteEndPoint= new IPEndPoint(row.remoteAddr,(int)remotePort);
37 // IPV6 version of the Tcp row
38 internal SystemTcpConnectionInformation(MibTcp6RowOwnerPid row) {
41 //port is returned in Big-Endian - most significant bit on left
42 //unfortunately, its done at the word level and not the dword level.
44 int localPort = row.localPort1 << 8 | row.localPort2;
45 int remotePort = ((state == TcpState.Listen) ? 0 : row.remotePort1 << 8 | row.remotePort2);
47 localEndPoint = new IPEndPoint(new IPAddress(row.localAddr, row.localScopeId), (int)localPort);
48 remoteEndPoint = new IPEndPoint(new IPAddress(row.remoteAddr, row.remoteScopeId), (int)remotePort);
52 public override TcpState State{get {return state;}}
53 public override IPEndPoint LocalEndPoint{get {return localEndPoint;}}
54 public override IPEndPoint RemoteEndPoint{get {return remoteEndPoint;}}