Click here to Skip to main content
15,884,473 members
Articles / Programming Languages / C#

C# WebServer Using Sockets

Rate me:
Please Sign up or sign in to vote.
5.00/5 (27 votes)
23 Jan 2014CPOL7 min read 103.5K   9.9K   161  
How to make a simple web server which supports GZIP compression, applications, and sessions.

namespace ServerCommonLibrary
{
    
    public enum ResponseAction{ 
        /// <summary>
        /// Send the response data 
        /// </summary>
        Send, 
        /// <summary>
        /// Do nothing
        /// </summary>
        Skip,
        /// <summary>
        /// Disconnect the connection
        /// </summary>
        Disconnect }


    /// <summary>
    /// RawResponse is generated by the provider and is sents back to the client
    ///  -the prefix Raw  because manage low level format data
    /// </summary>
    public class RawResponse
    {
        /// <summary>
        /// - costructor -
        /// </summary>
        /// <param name="req">initial request</param>
        public RawResponse(RawRequest req)
        {
            this.Request = req;
        }

        //#### initial request 
        public RawRequest Request { get; set; }
        //#### response action 
        public ResponseAction Action { get; set; }
        //#### response data
        public byte[] ResponseData { get; set; }

        public virtual byte[] ElaborateData()
        {
            return this.ResponseData;
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
United Kingdom United Kingdom
Alberto Biafelli,
Software Developer

Comments and Discussions