home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 2000 May / PCP163A.iso / Runimage / Cbuilder4 / Include / SESSION.H < prev    next >
Encoding:
C/C++ Source or Header  |  1999-01-26  |  3.3 KB  |  123 lines

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