You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

83 lines
2.3 KiB

#ifndef _SERVER_CORE_SERVER_MODULE_
#define _SERVER_CORE_SERVER_MODULE_
#include <stdio.h>
#include <signal.h>
#ifndef __linux__
// #include <WinSock2.h>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#else
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netdb.h>
#include <sys/un.h>
#include <sys/types.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <errno.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include "../../components/base/basicTypes.h"
#include "../../components/base/basicThread.h"
#include "../../components/base/basicLogCollection.h"
#include "../../components/base/basicLogCollection.h"
#include "../../components/base/basicSettingsProvider.h"
#include "../../components/base/basicEngine.h"
#include "../../components/base/basicEventHeap.h"
#include "../protocol/protocol.h"
#include "netClientHandler.h"
#define NWS_SETTINGS_HOST "NW_HOSTNAME_IP"
#define NWS_SETTINGS_PORT "NW_LISTEN_PORT"
//typedef _Primitive_Ring<_Core_Channel> ChannelsRing;
typedef std::vector<networkClientHandler *> vectorNetHandlers;
#define UNIX_PATH_MAX 108
void signal_void_handler( int SIG );
class networkServer: public basicThread, public basicEventHandler{
private:
basicLogCollection *m_pLog;
vectorNetHandlers m_vHandlersPool;
basicEngine *m_pDetectorKernel;
config_setting_t *m_pSettings;
struct sockaddr *MainSocketAddress;
CSTR m_pHostName;
uint16_t m_nPortNumber;
#ifdef __linux__
int MainSocket;
#else
SOCKET MainSocket;
#endif
U8 m_bConnectionType;
protected:
void m_fThreadProc( void );
public:
explicit networkServer( config_setting_t *Settings = NULL );
virtual ~networkServer();
bool BootUp( void ); // Config By Settings provided in constructor, on fail uses next BootUp
bool BootUp( U16 Port ); // Uses Default Hostname and Port as parameter, on fail (getlocalhost) uses next Bootup
bool BootUp( CSTR HOST_NAME, U16 Port ); // Uses parameters
#ifdef __linux__
bool BootUp( CSTR UNIX_SOCKET_NAME );
#endif
bool attachEngine( basicEngine *ptr );
void dispatchEvent( basicEvent *Evt );
};
#endif