コード例 #1
0
ファイル: Game.cs プロジェクト: Alintya/PoeSuite
        internal bool CloseTcpConnections(IpVersion ipVersion = IpVersion.Ipv4)
        {
            if (!IsValid)
            {
                return(false);
            }

            Logger.Get.Debug($"Trying to close tcp connections for pid {_proc.Id}");

            var connections = TcpHelper.GetTcpConnections(ipVersion, TcpTableClass.OwnerPidAll);

            if (connections.Count == 0)
            {
                Logger.Get.Warning($"There are no active tcp connections for {_proc.Id}");
                return(false);
            }

            foreach (var connection in connections.Where(x => x.OwningPid == _proc.Id))
            {
                if (!TcpHelper.CloseConnection(connection))
                {
                    // TODO
                    Logger.Get.Warning($"Could not kill tcp connection");
                    return(false);
                }
            }

            return(true);
        }