static void Main(string[] args) { Server s = new Server(); s.Run(); Client c1 = new Client(); Client c2 = new Client(); Client c3 = new Client(); c1.Connect(); c2.Connect(); c3.Connect(); CancellationTokenSource ct1 = new CancellationTokenSource(); CancellationTokenSource ct2 = new CancellationTokenSource(); CancellationTokenSource ct3 = new CancellationTokenSource(); var t1 = c1.keepPinging(ct1.Token); var t2 = c2.keepPinging(ct2.Token); var t3 = c3.keepPinging(ct3.Token); var tasks = new List <Task <IEnumerable <string> > >(); tasks.Add(t1); tasks.Add(t2); tasks.Add(t3); ct1.CancelAfter(2000); ct2.CancelAfter(3000); ct3.CancelAfter(4000); Task.WaitAll(tasks.ToArray()); Console.WriteLine("----------Logi Servera----------"); ServerLog serverlog = s.getServerLog(); serverlog.showLogs(); s.Stop(); Console.WriteLine("koniec main"); }
public Server() { address = IPAddress.Any; port = 2048; serverLog = new ServerLog(); }