コード例 #1
0
ファイル: ServerClass.cs プロジェクト: FrostieM/cloudProject
        private static void ProcessConnection(TcpClient client)
        {
            var ip = ((IPEndPoint)client.Client.LocalEndPoint).Address;

            Console.WriteLine($"New connection {ip}");
            try
            {
                NetworkStream stream = null;
                try
                {
                    stream = client.GetStream();
                    var container = AppsContainer.FromStream(stream);
                    dbWork.UpdateDB(container);
                    SheetsUpdater(dbWork.GetOneComputerData(container.hostname));
                }
                catch (Exception e) { Console.WriteLine(e); }
                finally{ stream?.Close(); Console.WriteLine($"Stream {ip} closed!"); }
            }
            catch (Exception e) { Console.WriteLine(e); }
            finally{ client.Close(); Console.WriteLine($"Connection {ip} closed!"); }
        }