home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / include / session.h < prev    next >
C/C++ Source or Header  |  1998-04-25  |  3KB  |  121 lines

  1.  
  2. #if !defined(SESSION_H)
  3. #define SESSION_H
  4.  
  5. /*
  6. ================================================================================
  7.     ========================================================================
  8.     ========================================================================
  9.  
  10.     File:           csession.h
  11.     Description:    
  12.     Created:        9/3/1997
  13.     Author:         Matthijs Gates
  14.     Mail:           mgates@microsoft.com
  15.  
  16.     Copyright (C) 1997  Microsoft Corporation.  All Rights Reserved.
  17.  
  18.     ========================================================================
  19.     ========================================================================
  20. ================================================================================
  21. */
  22.  
  23. #include "brtest.h"
  24. #include "util.h"
  25.  
  26. //==============================================================================
  27. //
  28. //  Class:  CSession
  29. //
  30. //------------------------------------------------------------------------------
  31. //  Description:        abstract root class for Sessions (Tunnels, Multicasts, 
  32. //                      etc...); provides a set of primitive methods that
  33. //                      sessions must implement
  34. //
  35. //  Public methods:
  36. //                      Send()      send a CData object over the session
  37. //
  38. //  Public properties:
  39. //                      - none -
  40. //
  41. //  9/3/1997
  42. //  mgates
  43. //
  44. //==============================================================================
  45. class CSession
  46. {
  47.     WSADATA m_wsaData ;
  48.     
  49.     enum { WINSOCK_MAJOR_VER = 2, WINSOCK_MINOR_VER = 0 } ;
  50.     
  51.     // P U B L I C
  52.  
  53.     public :
  54.     
  55.         CSession() ;
  56.         virtual ~CSession() ;
  57.     
  58.         virtual INT Send(CData &data) = 0 ;
  59.  
  60.     // P R O T E C T E D
  61.  
  62.     protected :
  63.  
  64. } ;
  65.  
  66. //==============================================================================
  67. //
  68. //  Class:  CMulticast
  69. //
  70. //------------------------------------------------------------------------------
  71. //  Description:
  72. //
  73. //  Public methods:
  74. //
  75. //  Public properties:
  76. //
  77. //  9/14/1997
  78. //  mgates@microsoft.com
  79. //
  80. //==============================================================================
  81. class CMulticast : public CSession
  82. {
  83.     CString     m_strIP ;
  84.     CString     m_strNIC ;
  85.     USHORT      m_usPort ;
  86.     SOCKET      m_socket ;
  87.     SOCKADDR_IN m_destinationAddr ;
  88.     SOCKADDR_IN m_thisAddr ;
  89.     USHORT      m_usTTL ;
  90.     
  91.     enum { DEF_TTL = 10 
  92.          } ;
  93.     
  94.     // P U B L I C -------------------------------------------------------------
  95.  
  96.     public :
  97.     
  98.         CMulticast() ;
  99.         virtual ~CMulticast() ;
  100.         
  101.         BOOL SetIP(CString &strIP) ;
  102.         BOOL SetIP(char *szIP) ;
  103.         
  104.         BOOL SetPort(USHORT usPort)     { m_usPort = usPort ; return TRUE ; }
  105.         
  106.         BOOL SetNIC(CString &strNIC) ;
  107.         BOOL SetNIC(char *szNIC) ;
  108.         
  109.         BOOL SetTTL(USHORT usTTL) { m_usTTL = usTTL ; return TRUE ; }
  110.         USHORT GetTTL() { return m_usTTL ; }
  111.         
  112.         BOOL Create() ;
  113.         INT  Send(CData &data) ;
  114.         
  115.         CString &GetIP()    { return m_strIP ; }
  116.         USHORT      GetPort()   { return m_usPort ; }
  117.         CString &GetNIC()   { return m_strNIC ; }
  118. } ;
  119.  
  120. #endif  // SESSION_H
  121.