Stop() public method

public Stop ( ) : void
return void
Exemplo n.º 1
0
        static void Main(string[] args)
        {
            // SSL server port
            int port = 2222;

            // If arguments are provided use the first one as a port number
            if (args.Length > 0)
            {
                port = int.Parse(args[0]);
            }

            Console.WriteLine($"SSL server port: {port}");

            Console.WriteLine();

            // Create and prepare a new SSL server context using TLS protocol
            // and pass the path for the server certificate.
            var context = new SslContext(SslProtocols.Tls12,
                                         new X509Certificate2(@"C:\Users\user\Downloads\server.pfx", "qwerty"));

            // Create a new SSL server instance
            var server = new SocketServer(context, IPAddress.Any, port);

            // Start the server
            Console.Write("Server starting...");
            server.Start();
            Console.WriteLine("Done!");

            Console.WriteLine("Press Enter to stop the server or '!' to restart the server...");

            // Perform text input
            do
            {
                string line = Console.ReadLine();

                if (string.IsNullOrEmpty(line))
                {
                    break;
                }

                // Restart the server if a special symbol is inputed
                if (line == "!")
                {
                    Console.Write("Server restarting...");
                    server.Restart();
                    Console.WriteLine("Done!");
                    continue;
                }

                // Multicast admin message to all sessions
                line = "(admin) " + line;
                server.Multicast(line);
            }while (true);

            // Stop the server
            Console.Write("Server stopping...");
            server.Stop();
            Console.WriteLine("Done!");
        }
Exemplo n.º 2
0
        public static void Main(string[] args) {
            var server = new SocketServer(IPAddress.Parse(Ip), Port);
            server.Start();

            var input = string.Empty;
            while (input.ToLower() != "q") {
                Console.WriteLine("Enter 'Q' or 'q' to exit.");
                input = Console.ReadLine().ToLower();
            }
            server.Stop();
            server.Dispose();
        }
Exemplo n.º 3
0
 private void BtnTurnOff_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
 {
     _server.Broadcast(new SocketPackage()
     {
         Action = SocketPackage.EnumAction.ServerShutdown
     });
     _server.Stop();
     btnTurnOn.IsEnabled  = true;
     btnTurnOff.IsEnabled = false;
     ShowInformation();
     ShowMessage("turn off server");
 }
Exemplo n.º 4
0
        public static void Main(string[] args)
        {
            var server = new SocketServer(IPAddress.Parse(Ip), Port);

            server.Start();

            var input = string.Empty;

            while (input.ToLower() != "q")
            {
                Console.WriteLine("Enter 'Q' or 'q' to exit.");
                input = Console.ReadLine().ToLower();
            }
            server.Stop();
            server.Dispose();
        }