Example #1
0
        /// <summary>
        /// Basic constructor using default address and port settings
        /// </summary>
        public HttpServer()
        {
            config = new SharpConfig();
            mimeTypes = new MimeTypes();
            CallbackSys = new CallbackSubSystem();

            if (config.loaded)
            {
                Modules = new ModuleServices(config, ref CallbackSys);
                Modules.FindModules();

                try
                {
                    Debug.WriteLine("Attempting to bind to " + config.directive["Address"] + ":" + config.directive["Port"]);
                    tcpListener = new TcpListener(IPAddress.Parse(config.directive["Address"]), Convert.ToInt32(config.directive["Port"])); // will default to any address and port 80 on this constructor
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Failed to bind to address or port. Exception: " + ex.Message);
                    Debug.WriteLine("Failed to bind to address or port. Exception: " + ex.Message);
                }
                PrepListenThread();
            }
            else
            {
                Console.WriteLine("config not loaded.");
            }
        }
Example #2
0
 public ModuleServices(SharpConfig loadedConfig, ref CallbackSubSystem cbSys)
 {
     config = loadedConfig;
     cbSystem = cbSys;
 }
Example #3
0
        /// <summary>
        /// Constructor allowing the specification of address and port to be bound to
        /// </summary>
        /// <param name="address"></param>
        /// <param name="port"></param>
        public HttpServer(IPAddress address, int port)
        {
            config = new SharpConfig();
            CallbackSys = new CallbackSubSystem();

            if (config.loaded)
            {
                Modules = new ModuleServices(config, ref CallbackSys);
                Modules.FindModules();

                try
                {
                    tcpListener = new TcpListener(address, port);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Failed to bind to address or port. Exception: " + ex.Message);
                    Debug.WriteLine("Failed to bind to address or port. Exception: " + ex.Message);
                }
                PrepListenThread();
            }
        }