Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            IPAddress   ip           = IPAddress.Parse("127.0.0.1");
            TcpListener serverSocket = new TcpListener(ip, 6789);

            serverSocket.Start();
            while (true)
            {
                TcpClient connectionSocket = serverSocket.AcceptTcpClient();
                Console.WriteLine("Server activated now");
                EchoService1 service  = new EchoService1(connectionSocket);
                Thread       myThread = new Thread(new ThreadStart(service.DoIt));
                myThread.Start();
                //Task.Factory.StartNew(service.doIt);
                // or use delegates Task.Factory.StartNew() => service.DoIt();
            }
            serverSocket.Stop();
        }
Exemplo n.º 2
0
        public static void Main(string[] args)
        {
            IPAddress.Parse("192.168.43.72");
            var serverSocket = new TcpListener(8080);

            serverSocket.Start();

            while (true)
            {
                TcpClient connectionSocket = serverSocket.AcceptTcpClient();

                Console.WriteLine("Server activated now!");
                var service = new EchoService1(connectionSocket);

                Task.Factory.StartNew(service.DoIt);

            }

            serverSocket.Stop();
        }
Exemplo n.º 3
0
        public static void Main(string[] args)
        {
            IPAddress.Parse("192.168.43.72");
            var serverSocket = new TcpListener(8080);

            serverSocket.Start();

            while (true)
            {
                TcpClient connectionSocket = serverSocket.AcceptTcpClient();

                Console.WriteLine("Server activated now!");
                var service = new EchoService1(connectionSocket);

                Task.Factory.StartNew(service.DoIt);
            }


            serverSocket.Stop();
        }
Exemplo n.º 4
0
        public static void Main(string[] args)
        {
            IPAddress ip = IPAddress.Parse("127.0.0.1");
            TcpListener serverSocket = new TcpListener(ip, 6789);

            //TcpListener serverSocket = new TcpListener(6789);
            serverSocket.Start();

            while (true)
            {
                TcpClient connectionSocket = serverSocket.AcceptTcpClient();
                Console.WriteLine("Server activated now");
                EchoService1 service = new EchoService1(connectionSocket);
                Thread myThread = new Thread(new ThreadStart(service.DoIt));
                myThread.Start();

                //Task.Factory.StartNew(service.doIt);
                // or use delegates Task.Factory.StartNew() => service.DoIt();
            }

            serverSocket.Stop();
        }