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 public SystemTcpConnectionInformation (IPEndPoint local, IPEndPoint remote, TcpState state)
26 localEndPoint = local;
27 remoteEndPoint = remote;
31 internal SystemTcpConnectionInformation(MibTcpRow row) {
34 //port is returned in Big-Endian - most significant bit on left
35 //unfortunately, its done at the word level and not the dword level.
37 int localPort = row.localPort1<<8|row.localPort2;
38 int remotePort = ((state == TcpState.Listen)?0:row.remotePort1<<8|row.remotePort2);
40 localEndPoint = new IPEndPoint(row.localAddr,(int)localPort);
41 remoteEndPoint= new IPEndPoint(row.remoteAddr,(int)remotePort);
44 // IPV6 version of the Tcp row
45 internal SystemTcpConnectionInformation(MibTcp6RowOwnerPid row) {
48 //port is returned in Big-Endian - most significant bit on left
49 //unfortunately, its done at the word level and not the dword level.
51 int localPort = row.localPort1 << 8 | row.localPort2;
52 int remotePort = ((state == TcpState.Listen) ? 0 : row.remotePort1 << 8 | row.remotePort2);
54 localEndPoint = new IPEndPoint(new IPAddress(row.localAddr, row.localScopeId), (int)localPort);
55 remoteEndPoint = new IPEndPoint(new IPAddress(row.remoteAddr, row.remoteScopeId), (int)remotePort);
59 public override TcpState State{get {return state;}}
60 public override IPEndPoint LocalEndPoint{get {return localEndPoint;}}
61 public override IPEndPoint RemoteEndPoint{get {return remoteEndPoint;}}