Example #1
0
        /// <summary>
        /// Class constructor
        /// </summary>
        /// <param name="Config">Server configuration</param>
        /// <param name="Security">Server credentials</param>
        /// <param name="PagesDirectory">Location where pages are stored</param>
        public HttpServer(Configuration Config, Credential Security, string PagesDirectory)
        {
            this.ram_stream        = null;
            this.ram_buffer        = null;
            this.ram_used          = false;
            this.server_thread     = null;
            this.listen_socket     = null;
            this.accepted_socket   = null;
            this.is_server_running = false;
            this.storage_path      = PagesDirectory;
            this.recieve_buffer    = null;
            this.send_buffer       = new byte[256];
            is_polled               = false;
            data_size               = 0;
            this.server_thread      = new Thread(new ThreadStart(run_server));
            this.server_config      = Config;
            this.server_credential  = Security;
            this.use_authentication = true;

            if (!server_config.DhcpEnabled)
            {
                NetworkInterface networkInterface = NetworkInterface.GetAllNetworkInterfaces()[0];
                networkInterface.EnableStaticIP(server_config.IpAddress, server_config.SubnetMask, server_config.DefaultGateWay);
                Thread.Sleep(1000);
            }
        }
Example #2
0
        /// <summary>
        /// Class constructor used with 23K640 ram as an external memory recieve buffer
        /// </summary>
        /// <param name="Config">Server configuration</param>
        /// <param name="PagesDirectory">Pages directory</param>
        /// <param name="RamChipSelectPin">Chip select Pin 23K640</param>
        /// <param name="RamHoldPin">Hold Pin 23K640</param>
        public HttpServer(Configuration Config, string PagesDirectory, Cpu.Pin RamChipSelectPin, Cpu.Pin RamHoldPin)
        {
            this.ram_stream        = new RamStream(RamChipSelectPin, RamHoldPin);
            this.ram_buffer        = new RamString(this.ram_stream);
            this.ram_used          = true;
            this.server_thread     = null;
            this.listen_socket     = null;
            this.accepted_socket   = null;
            this.is_server_running = false;
            this.storage_path      = PagesDirectory;
            this.recieve_buffer    = null;
            this.send_buffer       = new byte[256];
            is_polled               = false;
            data_size               = 0;
            this.server_thread      = new Thread(new ThreadStart(run_server));
            this.server_config      = Config;
            this.use_authentication = false;

            if (!server_config.DhcpEnabled)
            {
                NetworkInterface networkInterface = NetworkInterface.GetAllNetworkInterfaces()[0];
                networkInterface.EnableStaticIP(server_config.IpAddress, server_config.SubnetMask, server_config.DefaultGateWay);
                Thread.Sleep(1000);
            }
            while (!ram_stream_verification())
            {
                ;
            }
        }
Example #3
0
 /// <summary>
 /// Class constructor, initializes position to a specified address
 /// </summary>
 /// <param name="stream">RamStream object</param>
 /// <param name="address">address to store strings</param>
 public RamString(RamStream stream, int address)
 {
     this.stream   = stream;
     this.position = address;
 }
Example #4
0
 /// <summary>
 /// Class constructor, initializes position to address 0
 /// </summary>
 /// <param name="stream">RamStream object</param>
 public RamString(RamStream stream)
 {
     this.stream   = stream;
     this.position = 0;
 }