winzip icon

MFC classes to implement a Web Server

Email
Submitted on: 1/1/2015 2:37:00 AM
By: PJ Naughter (from psc cd)  
Level: Intermediate
User Rating: By 5 Users
Compatibility: C++ (general)
Views: 3470
 
     3Mfc 1.1 A collection of freeware MFC classes to implement a Web Server Welcome to W3Mfc, a collection of freeware MFC classes to implement a simple Web server. The idea behind is W3Mfc was originally to learn about the Http protocol and how it is implemented on Win32. It is not intended to be a replacement for IIS or Apache. Instead it is designed as a tool for learning or in cases where deployment of a solution on IIS would be considered overkill or your product must run on 95/98 in addition to NT. For detailed information about the Hyper Text Transfer Protocol you should read RFC 1945, You can download this from a number of sites by searching for RFC and 1945 on www.yahoo.com. Another document that these classes refer to is RFC 2045 which defines MIME. The classes which constitute W3Mfc are: CHttpServerSettings: This class contains the settings which are used to configure the web server. Example member variables in this class include the root directory and the default filename. If you are developing a stand alone web server based on W3Mfc, you could for example store all the variables for the CHttpServerSettings instance in an ini file or in the registry. In the future this is the class which will be extended to include additional settings such as multiple virtual directories. CHttpServer: This is the actual class which implements the web server. It has a number of very simple functions to allow you to control the state of the web server such as Start and Stop. Internally a background thread is spun off to handle the client connections. CHttpSocket: This is a simple C++/MFC encapsulation of an SDK socket. CHttpResponseHeader: This class helps in the handling of sending request headers when returning the HTTP responses to clients. It provides a number of methods to allow standard Http headers to be added to the client response. CHttpMimeManager: This class is used when returning client responses. It is used to determine the mime type of a file given its extension type. This information is taken from the registry and is cached in this class. For example, files of .htm or .html will normally be of mime type "text/html". CHttpRequest: This class represents a request from a client. It contains information such as the URI of the request, the Http Verb used and the Http version used for the request. A member of this type is stored in the CHttpClient class. CHttpClient: This class is used in the CHttpServer class to handle client connections. It handles the parsing of client requests and returning the appropriate response. A number of virtual functions are provided to allow end user customization. The enclosed zip file contains the W3Mfc source code and a simple console based application which implements a simple web server. PJ Naughter at http://indigo.ie/~pjn/index.html
 
winzip iconDownload code

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzip to decompress it.Virus note:All files are scanned once-a-day by Planet Source Code for viruses, but new viruses come out every day, so no prevention program can catch 100% of them. For your own safety, please:
  1. Re-scan downloaded files using your personal virus checker before using it.
  2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

If you don't have a virus scanner, you can get one at many places on the net including:McAfee.com


Other 10 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.