- Main Page
- Classes
- Files

- File List
- File Members

# E:/uas2/Server/CharacterServer.h

Go to the documentation of this file.

    00001 /*
    00002 * This file is part of UAS2.
    00003 *
    00004 * UAS2 is free software; you can redistribute it and/or modify
    00005 * it under the terms of the GNU General Public License as published by
    00006 * the Free Software Foundation; either version 2 of the License, or
    00007 * (at your option) any later version.
    00008 *
    00009 * UAS2 is distributed in the hope that it will be useful,
    00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00012 * GNU General Public License for more details.
    00013
    00014 * You should have received a copy of the GNU General Public License
    00015 * along with UASv1; if not, write to the Free Software
    00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    00017 */
    00018
    00023 #ifndef __CHARACTERSERVER_H
    00024 #define __CHARACTERSERVER_H
    00025
    00026 #include "uas.h"
    00027
    00028 class cCharacterServer
    00029 {
    00030         friend class cMasterServer;
    00031
    00032 public:
    00033         static DWORD m_dwClientCount;
    00034         static DWORD ReturnPadOffset( DWORD dwLength );
    00035         static void Initialize( short nPort, WORD wLogicalID, DWORD dwSendCRCSeed, DWORD dwRecvCRCSeed )
    00036         {
    00037                 UpdateConsole( "\r\n Starting Character Server ... " );
    00038
    00039                 SOCKADDR_IN     saSockAddr;
    00040                 saSockAddr.sin_family           = AF_INET;
    00041                 saSockAddr.sin_port                     = htons( nPort );
    00042                 saSockAddr.sin_addr.s_addr      = INADDR_ANY;
    00043
    00044                 m_wLogicalID    = wLogicalID;
    00045                 m_dwSendCRCSeed = dwSendCRCSeed;
    00046                 m_dwRecvCRCSeed = dwRecvCRCSeed;
    00047
    00048                 m_Socket = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP );
    00049                 if ( !m_Socket )
    00050                 {
    00051                         UpdateConsole( "socket( ) failed!\r\n" );
    00052                         return ;
    00053                 }
    00054
    00055                 if ( bind( m_Socket, (struct sockaddr *)&saSockAddr, sizeof( SOCKADDR_IN ) ) )
    00056                 {
    00057                         UpdateConsole( "bind( ) failed!\r\n" );
    00058                         return ;
    00059                 }
    00060
    00061                 UpdateConsole( "success.\r\n" );
    00062         }
    00063
    00064         static void Halt( )
    00065         {
    00066                 closesocket( m_Socket );
    00067                 UpdateConsole( " Character Server: closing socket ...\r\n" );
    00068         }
    00069
    00070 protected:
    00071         static DWORD    m_dwSendCRCSeed;
    00072         static DWORD    m_dwRecvCRCSeed;
    00073         static WORD             m_wLogicalID;
    00074         static SOCKET   m_Socket;
    00075 };
    00076
    00077 #endif  // #ifndef __CHARACTERSERVER_H