BeardedManStudios.Network.SocketPolicyServer.Start C# (CSharp) Метод

Start() публичный Метод

Start the Socket Policy Server
public Start ( ) : void
Результат void
		public void Start()
		{
			if (Busy)
				return;

			try
			{
				listen_socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
				listen_socket.Bind(new IPEndPoint(IPAddress.Any, 843));
				listen_socket.Listen(500);
				listen_socket.Blocking = false;
				Busy = true;
			}
			catch (SocketException se)
			{
				// Most common mistake: port 843 is not user accessible on unix-like operating systems
				if (se.SocketErrorCode == SocketError.AccessDenied)
				{
					Console.WriteLine("NOTE: must be run as root since the server listen to port 843");
				}
				else
				{
					Console.WriteLine(se);
				}
			}

			runner = new Thread(new ThreadStart(RunServer));
			runner.Start();
		}

Usage Example

Пример #1
0
        /// <summary>
        /// Begin the Socket Policy Server
        /// </summary>
        /// <param name="xmlType">XML Type to be used</param>
        /// <param name="fileLocation">Location of the policy file</param>
        public static void Begin(XMLType xmlType = XMLType.All, string fileLocation = "")
        {
            string policy = null;

            switch (xmlType)
            {
            case XMLType.All:
                policy = AllPolicy;
                break;

            case XMLType.Local:
                policy = LocalPolicy;
                break;

            case XMLType.File:
                if (fileLocation.Length < 2)
                {
                    UnityEngine.Debug.LogError("Missing policy file name");
                    throw new NetworkException("Missing policy file name");
                }

                if (!File.Exists(fileLocation))
                {
                    UnityEngine.Debug.LogError("Could not find policy file '" + fileLocation + "'.");
                    throw new NetworkException("Could not find policy file '" + fileLocation + "'.");
                }
                using (StreamReader sr = new StreamReader(fileLocation))
                {
                    policy = sr.ReadToEnd();
                }
                break;
            }

            server = new SocketPolicyServer(policy);
            server.Start();
        }
All Usage Examples Of BeardedManStudios.Network.SocketPolicyServer::Start