当前位置: 首页>>代码示例>>C#>>正文


C# Server.Stop方法代码示例

本文整理汇总了C#中Server.Stop方法的典型用法代码示例。如果您正苦于以下问题:C# Server.Stop方法的具体用法?C# Server.Stop怎么用?C# Server.Stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Server的用法示例。


在下文中一共展示了Server.Stop方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

	static void Main (string [] args)
	{
		Server http = new Server ();
		Proxy proxy = new Proxy ();

		new Thread (http.Run).Start ();
		new Thread (proxy.Run).Start ();

		IPAddress ip = GetIPv4Address (Dns.GetHostName ());

		HttpWebRequest request = (HttpWebRequest) WebRequest.Create ("http://" + ip.ToString () + ":8080/default.htm");
		request.Proxy = new WebProxy (ip.ToString (), 8081);

		try {
			HttpWebResponse response = (HttpWebResponse) request.GetResponse ();
			Assert.IsNull (response.CharacterSet, "#A1");
			Assert.AreEqual (HttpStatusCode.OK, response.StatusCode, "#A2");
			Assert.AreEqual (string.Empty, response.ContentEncoding, "#A3");
			Assert.AreEqual (string.Empty, response.ContentType, "#A4");

			using (StreamReader sr = new StreamReader (response.GetResponseStream ())) {
				string body = sr.ReadToEnd ();
				Assert.AreEqual ("<html><body>ok</body></html>", body, "#A5");
			}
		} catch (WebException ex) {
			if (ex.Response != null) {
				StreamReader sr = new StreamReader (ex.Response.GetResponseStream ());
				Console.WriteLine (sr.ReadToEnd ());
			}
			throw;
		} finally {
			http.Stop ();
			proxy.Stop ();
		}
	}
开发者ID:mono,项目名称:gert,代码行数:35,代码来源:test.cs

示例2: Main

        public static void Main(string[] args)
        {
            string name = "Foobar Mirror";
            ushort port = 3690;

            if (args.Length > 0)
                name = args[0];
            if (args.Length > 1)
                port = UInt16.Parse (args[1]);

            server = new Server (name);
            server.Port = port;
            server.Start ();

            ServiceLocator locator = new ServiceLocator ();
            locator.Found += OnServiceFound;
            locator.Removed += OnServiceRemoved;
            locator.Start ();

            Console.WriteLine ("Press enter to quit");
            Console.ReadLine ();

            foreach (Client client in clients) {
                client.Logout ();
            }

            locator.Stop ();
            server.Stop ();
        }
开发者ID:mono,项目名称:daap-sharp,代码行数:29,代码来源:Mirror.cs

示例3: Start

        /// <summary>
        /// Starts the web server.
        /// </summary>
        public void Start()
        {
            new Thread(() =>
            {
                // create the cross process service
                var svcHost = new ServiceHost(_serviceProvider, new Uri("net.pipe://localhost/testhost"));
                svcHost.AddServiceEndpoint(typeof(ITestHostService), new NetNamedPipeBinding(), "");

                // service must be set to single instance mode 
                svcHost.Description.Behaviors.Find<ServiceBehaviorAttribute>()
                    .InstanceContextMode = InstanceContextMode.Single;

                // open and wait for close event
                svcHost.Open();
                _hostCloseEvent.WaitOne();
                svcHost.Close();
            }).Start();

            new Thread(() =>
            {
                // start the web server process
                var server = new Server(_port, "/", _physicalPath);

                // start and wait for cstop event
                server.Start();
                _serverStopEvent.WaitOne();
                server.Stop();
            }).Start();
        }
开发者ID:JimmyJune,项目名称:blade,代码行数:32,代码来源:TestServer.cs

示例4: OneHundredConcurrentSimpleGet

 public void OneHundredConcurrentSimpleGet()
 {
     var server = new Server(3003);
     server.Start(Application.Run);
     var uri = new Uri("http://localhost:3003/");
     var bag = new ConcurrentBag<string>();
     const int count = 100;
     for (int i = 0; i < count; i++)
     {
         var client = new WebClient();
         client.DownloadStringCompleted += (sender, args) =>
             {
                 bag.Add(args.Result);
                 client.Dispose();
             };
         client.DownloadStringAsync(uri);
     }
     SpinWait.SpinUntil(() => bag.Count == count, 10000);
     server.Stop();
     Assert.Equal(count, bag.Count);
     foreach (var actual in bag)
     {
         Assert.Equal(Index.Html, actual);
     }
 }
开发者ID:bentayloruk,项目名称:Flux,代码行数:25,代码来源:HttpClientGetTest.cs

示例5: ServerThreadStart

 public void ServerThreadStart()
 {
     try
     {
         Server server = new Server();
         server.SaveFilenameOverride = savefilename;
         server.exit = exit;
         DummyNetServer netServer = new DummyNetServer();
         netServer.SetPlatform(new GamePlatformNative());
         netServer.SetNetwork(dummyNetwork);
         server.mainSockets = new NetServer[3];
         server.mainSockets[0] = netServer;
         for (; ; )
         {
             server.Process();
             Thread.Sleep(1);
             platform.singlePlayerServerLoaded = true;
             if (exit != null && exit.GetExit()) { server.Stop(); break; }
             if (platform.singlepLayerServerExit)
             {
                 // Exit thread and reset shutdown variable
                 server.Exit();
                 platform.singlepLayerServerExit = false;
             }
         }
         exit.SetExit(false);
     }
     catch (Exception e)
     {
         MessageBox.Show(e.ToString());
     }
 }
开发者ID:Matthewism,项目名称:manicdigger,代码行数:32,代码来源:Program.cs

示例6: Main

 public static void Main(string[] args)
 {
     Server Servidor = new Server("127.0.0.1", 7777);
       Servidor.Start();
       Servidor.Stop();
       System.Console.WriteLine("ya ta!!");
 }
开发者ID:alvarezdaniel,项目名称:inworx-curso-dotnet,代码行数:7,代码来源:ServerUI.cs

示例7: Use

 public void Use(Server server, string[] tokens)
 {
     server.Broadcast("The server is shutting down.");
     server.Logger.Log(Logger.LogLevel.Info, "The server is shutting down.");
     Thread.Sleep(5000);
     server.Stop();
     Thread.Sleep(10);
     Console.WriteLine("Press Enter to exit.");
 }
开发者ID:AVATAR-Phoenix,项目名称:c-raft,代码行数:9,代码来源:CmdStop.cs

示例8: Main

        static void Main(string[] args)
        {
            var application = new Application();
            var server = new Server(application.App, 3000);

            server.Start();

            System.Console.WriteLine("Running on port 3000");
            System.Console.Write("Press Enter to quit: ");
            System.Console.ReadLine();
            server.Stop();
        }
开发者ID:markrendle,项目名称:Simple.WebServer,代码行数:12,代码来源:Program.cs

示例9: Main

        static void Main(string[] args)
        {
            // Creates the server
            Server server = new Server();

            // Starts the server
            server.Start(8000);

            while (Console.ReadLine() != "quit");

            // Stops the server
            server.Stop();
        }
开发者ID:WoLfulus,项目名称:Almirante,代码行数:13,代码来源:Program.cs

示例10: ConnectPressed

 public RedirectResult ConnectPressed(Models.IndexModel Model)
 {
     // Create the server
     Main = new Server(Port);
     Main.Start();
     if (!Main.Connect(Model.ID))
     {
         Main.Stop();
         // Server failed to connect
         return Redirect("ConnectFailed");
     }
     // Server connected succesfully
     return Redirect("Controller");
 }
开发者ID:hnefatl,项目名称:Iliad-IV,代码行数:14,代码来源:IndexController.cs

示例11: SimpleGet

        public void SimpleGet()
        {
            var server = new Server(3001);
            server.Start(Application.Run);

            string actual;
            using (var client = new WebClient())
            {
                actual = client.DownloadString("http://localhost:3001/");
            }

            server.Stop();
            Assert.Equal(Index.Html, actual);
        }
开发者ID:bentayloruk,项目名称:Flux,代码行数:14,代码来源:HttpClientGetTest.cs

示例12: Main

        static void Main(string[] args)
        {
            var server = new Server(5002);

            var game = new Game(server, new ConsoleLogging());

            server.Start();

            Console.WriteLine("Running...");

            Console.ReadLine();

            server.Stop();
        }
开发者ID:FacticiusVir,项目名称:ScavengerMUD,代码行数:14,代码来源:Program.cs

示例13: ClientFullDataEmpty

        public void ClientFullDataEmpty()
        {
            Listener listener = new Listener(endPoint);
            ClientsManager clientsManager = new ClientsManager();
            Server server = new Server(listener, clientsManager);
            server.Start();

            protocol.Connect(endPoint, ref desktopSocket);
            protocol.SendObject(new Command(Command.Commands.FullData, string.Empty), desktopSocket);
            Command com = protocol.ReadObject(desktopSocket, typeof(Command)) as Command;

            server.Stop();
            Assert.AreEqual(0, com.ValuesList.Count);
        }
开发者ID:vit2005,项目名称:Multitier-Project,代码行数:14,代码来源:TestsServer.cs

示例14: Main

        static void Main(string[] args)
        {
            using (var serv = new Server())
            {
                Console.WriteLine("Starting server...");
                serv.Start();
                Console.WriteLine("Listening. Press any key to stop.");
                Console.ReadKey();
                Console.WriteLine("Stopping server...");
                serv.Stop();
                Console.WriteLine("Stopped.");
            }

            Console.WriteLine("Fin. Press any key to exit.");
            Console.ReadKey();
        }
开发者ID:jzebedee,项目名称:Taj,代码行数:16,代码来源:Program.cs

示例15: Main

        static void Main(string[] args)
        {
			var server = new Server("localhost", 13337);

			server.Get("http://localhost:13337/", (req, res) => res.Write("Hello World!").Close());

            //to have json output uncomment the next line and comment out the previous one.
            //server.Get("http://localhost:13337" ,(req, res) => res.WriteAsJson(new {Hello = "world"}));

            server.Start();
			Console.WriteLine("Server running");
			while (Console.ReadLine() == null)
				Thread.Sleep(100);

            server.Stop();
        }
开发者ID:coolya,项目名称:logv.http,代码行数:16,代码来源:Program.cs


注:本文中的Server.Stop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。