Class Hierarchy   Class Index   Method Index  

CHMmfcSocketTransport.h

00001 #ifndef __CHM_MFC_SOCKET_TRANSPORT_H__
00002 #define __CHM_MFC_SOCKET_TRANSPORT_H__
00003 //---------------------------------------------------------------------------
00004 // Copyright (C) 1997-2007 iNTERFACEWARE Inc.  All Rights Reserved
00005 //
00006 // Module: CHMmfcSocketTransport
00007 //
00008 // Author: Greg Norman
00009 // Revision: $Revision: 1.9 $
00010 //
00011 // Last Edit Date: $Date: 2007-02-12 21:35:42 $
00012 // Source: $Source: /home/cvs/cvsroot/CHM/CHMmfcSocketTransport.h,v $
00013 //---------------------------------------------------------------------------
00014 #include <CHM/CHMtransport.h>
00015 
00016 #if _MSC_VER > 1000
00017 #pragma once
00018 #endif // _MSC_VER > 1000
00019 #include <afxsock.h>
00020 
00021 
00022 // private member class
00023 class CHMmfcSocketTransportPrivate;
00024 
00032 class CHMmfcSocketTransport 
00033  : public CHMtransport, 
00034    public CSocket
00035 {
00036 public:
00041    CHMmfcSocketTransport();
00043    virtual ~CHMmfcSocketTransport();
00044 
00046    virtual void Close();
00047    
00049    virtual BOOL Connect(LPCTSTR Host, UINT PortNumber);
00050    
00051 
00052    enum
00053    {
00054       SOCKET_DOES_NOT_EXIST = 0x8001,
00055       SOCKET_NOT_A_SERVER   = 0x8002
00056    };
00057 
00058    // ClassWizard generated virtual function overrides
00059    //{{AFX_VIRTUAL(CHMsocket)
00061    virtual void OnReceive(int nErrorCode);
00063    virtual void OnAccept(int nErrorCode);
00065    virtual void OnClose(int nErrorCode);
00066    //}}AFX_VIRTUAL
00067 
00068    // Generated message map functions
00069    //{{AFX_MSG(CHMsocket)
00070    // NOTE - the ClassWizard will add and remove
00071    // member functions here.
00072    //}}AFX_MSG
00073 
00078    virtual void SendMessage(const CHMstring& Data);
00079    
00085    virtual void SendResponseMessage(const CHMstring& MessageData,
00086                                     size_t TransportIndex);   
00087 
00092    const size_t& TransportIndex() const;
00093 
00094 private:
00095    CHMmfcSocketTransportPrivate* pMember;
00096    // not allowed
00097    CHMmfcSocketTransport(const CHMmfcSocketTransport& Orig);
00098    CHMmfcSocketTransport& operator=(const CHMmfcSocketTransport& Orig);
00099    void GetDataWithoutNullChars(CHMstring& Buffer, size_t CountOfChar);
00100 };
00101 
00102 #endif // end of defensive include