Пример #1
0
 static void Main(string[] args)
 {
     ThreadPool.SetMinThreads(2, 2);
     ThreadPool.SetMaxThreads(Environment.ProcessorCount * 4, Environment.ProcessorCount * 4);
     try
     {
         Server = new ServerObject();
         //ThreadPool.QueueUserWorkItem(new WaitCallback(Server.Listen));
         ListenThread = new Thread(new ThreadStart(Server.Listen));
         ListenThread.Start();
     }
     catch (Exception ex)
     {
         Server.Disconnect();
         Console.WriteLine(ex.Message);
     }
 }
Пример #2
0
        static void Main(string[] args)
        {
            ServerObject s = new ServerObject();

            s.Listen();

            //client = new TcpClient();
            //client.Connect("192.168.31.137", 5454);
            //str = client.GetStream();

            //string message = "";
            //byte[] data = Encoding.Unicode.GetBytes(message);
            //str.Write(data, 0, data.Length);

            // запускаем новый поток для получения данных
            Thread receiveThread = new Thread(new ThreadStart(ReceiveMessage));

            receiveThread.Start(); //старт потока

            //SendMessage();
        }