public static string[] Connections(DisconnectWrapper.ConnectionState state) { DisconnectWrapper.ConnectionInfo[] tcpTable = DisconnectWrapper.getTcpTable(); ArrayList arrayList = new ArrayList(); foreach (DisconnectWrapper.ConnectionInfo connectionInfo in tcpTable) { if (state == DisconnectWrapper.ConnectionState.All || state == (DisconnectWrapper.ConnectionState)connectionInfo.dwState) { string text = DisconnectWrapper.IPIntToString(connectionInfo.dwLocalAddr) + ":" + DisconnectWrapper.ntohs(connectionInfo.dwLocalPort); string text2 = DisconnectWrapper.IPIntToString(connectionInfo.dwRemoteAddr) + ":" + DisconnectWrapper.ntohs(connectionInfo.dwRemotePort); arrayList.Add(string.Concat(new object[] { text, "-", text2, "-", ((DisconnectWrapper.ConnectionState)connectionInfo.dwState).ToString(), "-", connectionInfo.dwState })); } } return((string[])arrayList.ToArray(typeof(string))); }
public static void CloseLocalPort(int port) { DisconnectWrapper.ConnectionInfo[] tcpTable = DisconnectWrapper.getTcpTable(); for (int i = 0; i < tcpTable.Length; i++) { if (port == DisconnectWrapper.ntohs(tcpTable[i].dwLocalPort)) { tcpTable[i].dwState = 12; IntPtr ptrToNewObject = DisconnectWrapper.GetPtrToNewObject(tcpTable[i]); int num = DisconnectWrapper.SetTcpEntry(ptrToNewObject); } } }
public static void CloseLocalIP(string IP) { DisconnectWrapper.ConnectionInfo[] tcpTable = DisconnectWrapper.getTcpTable(); for (int i = 0; i < tcpTable.Length; i++) { if (tcpTable[i].dwLocalAddr == DisconnectWrapper.IPStringToInt(IP)) { tcpTable[i].dwState = 12; IntPtr ptrToNewObject = DisconnectWrapper.GetPtrToNewObject(tcpTable[i]); int num = DisconnectWrapper.SetTcpEntry(ptrToNewObject); } } }