session.h

来自「决战帝王1.5武神降临对喜爱决战的玩家共享研究用」· C头文件 代码 · 共 121 行

H
121
字号

#if !defined(SESSION_H)
#define SESSION_H

/*
================================================================================
    ========================================================================
    ========================================================================

    File:           csession.h
    Description:    
    Created:        9/3/1997
    Author:         Matthijs Gates
    Mail:           mgates@microsoft.com

    Copyright (C) 1997  Microsoft Corporation.  All Rights Reserved.

    ========================================================================
    ========================================================================
================================================================================
*/

#include "brtest.h"
#include "util.h"

//==============================================================================
//
//  Class:  CSession
//
//------------------------------------------------------------------------------
//  Description:        abstract root class for Sessions (Tunnels, Multicasts, 
//                      etc...); provides a set of primitive methods that
//                      sessions must implement
//
//  Public methods:
//                      Send()      send a CData object over the session
//
//  Public properties:
//                      - none -
//
//  9/3/1997
//  mgates
//
//==============================================================================
class CSession
{
    WSADATA m_wsaData ;
    
    enum { WINSOCK_MAJOR_VER = 2, WINSOCK_MINOR_VER = 0 } ;
    
    // P U B L I C

    public :
    
        CSession() ;
        virtual ~CSession() ;
    
        virtual INT Send(CData &data) = 0 ;

    // P R O T E C T E D

    protected :

} ;

//==============================================================================
//
//  Class:  CMulticast
//
//------------------------------------------------------------------------------
//  Description:
//
//  Public methods:
//
//  Public properties:
//
//  9/14/1997
//  mgates@microsoft.com
//
//==============================================================================
class CMulticast : public CSession
{
    CString     m_strIP ;
    CString     m_strNIC ;
    USHORT      m_usPort ;
    SOCKET      m_socket ;
    SOCKADDR_IN m_destinationAddr ;
    SOCKADDR_IN m_thisAddr ;
    USHORT      m_usTTL ;
    
    enum { DEF_TTL = 10 
         } ;
    
    // P U B L I C -------------------------------------------------------------

    public :
    
        CMulticast() ;
        virtual ~CMulticast() ;
        
        BOOL SetIP(CString &strIP) ;
        BOOL SetIP(char *szIP) ;
        
        BOOL SetPort(USHORT usPort)     { m_usPort = usPort ; return TRUE ; }
        
        BOOL SetNIC(CString &strNIC) ;
        BOOL SetNIC(char *szNIC) ;
        
        BOOL SetTTL(USHORT usTTL) { m_usTTL = usTTL ; return TRUE ; }
        USHORT GetTTL() { return m_usTTL ; }
        
        BOOL Create() ;
        INT  Send(CData &data) ;
        
        CString &GetIP()    { return m_strIP ; }
        USHORT      GetPort()   { return m_usPort ; }
        CString &GetNIC()   { return m_strNIC ; }
} ;

#endif  // SESSION_H

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?