Click here to Skip to main content
15,896,466 members
Articles / Desktop Programming / MFC

Extendable Webserver

Rate me:
Please Sign up or sign in to vote.
3.67/5 (8 votes)
6 Mar 2003CPOL2 min read 81K   1.7K   21  
An example of an extendible webserver using PJ Naughter's MFC library
/*
Module : HTTPSOCKET.H
Purpose: Defines the interface for a simple MFC socket wrapper class
Created: PJN / 22-04-1999
History: None

Copyright (c) 1999 - 2003 by PJ Naughter.  (Web: www.naughter.com, Email: pjna@naughter.com)

All rights reserved.

Copyright / Usage Details:

You are allowed to include the source code in any product (commercial, shareware, freeware or otherwise) 
when your product is released in binary form. You are allowed to modify the source code in any way you want 
except you cannot modify the copyright details at the top of each module. If you want to distribute source 
code with your application, then you are only allowed to distribute versions released by the author. This is 
to maintain a single distribution point for the source code. 

*/


/////////////////////////////// Defines ///////////////////////////////////////

#ifndef __HTTPSOCKET_H__
#define __HTTPSOCKET_H__




/////////////////////////////// Includes //////////////////////////////////////

#include "SocMFC.h"
#include "HttpRequest.h"
#include "W3MFC.h"
#ifdef W3MFC_SSL_SUPPORT
#include "OpenSSLMfc.h"
#endif
#include "WTimer.h" //If the code fails to compile because of this missing include then you need to download 
                    //the CWaitableTimer class from my web site and copy the relavent files to the W3MFC directory



/////////////////////////////// Classes ///////////////////////////////////////

class CHttpClient;

class CHttpSocket : public CWSocket
{
public:
//methods
  BOOL SplitRequestLine(LPSTR pszLine, CString& sField, CString& sValue);
  BOOL SplitRequestLine(const CString& sLine, CString& sField, CString& sValue);
  BOOL ReadResponse(CHttpRequest& request, DWORD dwTimeout, int nGrowBy, CHttpClient& client);
  BOOL ReadResponse(CHttpRequest& request, DWORD dwTimeout, int nGrowBy, CHttpClient& client, CWaitableTimer& timer, HANDLE hStopEvent, HANDLE hDataEvent);
  void SendWithRetry(void* pBuffer, int nBuf, DWORD dwTimeout);
#ifdef W3MFC_SSL_SUPPORT
  BOOL ReadResponse(CHttpRequest& request, DWORD dwTimeout, int nGrowBy, CSSL& ssl, CHttpClient& client);
  BOOL ReadResponse(CHttpRequest& request, DWORD dwTimeout, int nGrowBy, CSSL& ssl, CHttpClient& client, CWaitableTimer& timer, HANDLE hStopEvent, HANDLE hDataEvent);
  void SendWithRetry(void* pBuffer, int nBuf, DWORD dwTimeout, CSSL& ssl);
#endif

protected:
  CEvent m_WSABlockEvent;  //Used to implemented SocketSendWithRetry
};

#endif //__HTTPSOCKET_H__

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
ETA
Software Developer (Senior)
Netherlands Netherlands
I'm a 31 year old full-time programmer ('76).
(Currently: Lead Software System Designer)

Comments and Discussions