Example #1
0
void CNetManager::ServerClose()
{
	m_pIocpHandler->CloseAllThreads(THREAD_DIE_WAITTIME); // IOCP Worker Thread Close
	ServerLog()->Log("IOCP Worker Thread All Died.");
	m_pProcessThread->End(THREAD_DIE_WAITTIME); // ProcesssThread Close
	ServerLog()->Log("Process Thread Died.");

	// 모든 사용자 종료
	CUserList * pUserList = SMemManager()->GetUserList();
	CUser * pUser = pUserList->GetFirstUser();
	while(pUser != NULL)
	{
		m_pPacketProcess->CloseClient(pUser, false);
		pUser = pUserList->GetNext(pUser);
	}

	m_pAcceptThread->End(THREAD_DIE_WAITTIME);
	ServerLog()->Log("Accept Process Thread Die.");

	// 타이머 해제 윈도우 2000 전용함수 Platform SDK 업데이트 해야됨
	if(!DeleteTimerQueueTimer(NULL, m_hTimerQTimer, NULL))
	{
		ServerLog()->Log("Delete Timer Error.");
	}
	m_hTimerQTimer = NULL;

	CleanMemory();
	InitializeVariable();

	delete SCMemoryManager::GetMemManager(); // 메모리 관리 클래스 소멸
	delete SCProfile::GetProfile(); // Profile 클래스 소멸

	ServerLog()->Log("Server Close.\n");
}
Example #2
0
SCMemoryManager::SCMemoryManager()
{
	InitializeVariable();
}
BOOL CSerialServer::Connect(char *pszDevice, DWORD dwBaudRate, int nParity, int nDataBit, int nStopBit, BOOL bFlowControl)
{
#ifdef WINCE
	CString	strDevice;
#endif
	if (IsConnected())
		return FALSE;

	if (!pszDevice || !*pszDevice)
		return FALSE;

	m_bUseFlowControl = bFlowControl;
	if (!InitializeVariable())
		return FALSE;

	strcpy(m_szDevice, pszDevice);
    m_dwBaudRate		= dwBaudRate;
	m_nByteSize			= nDataBit;
	m_nParity			= nParity;
	m_nStopBits			= nStopBit;
	m_dwOldModemStatus	= 0;
	m_dwModemStatus		= 0;
	m_dwErrorsOld		= 0;
	m_dwErrors			= 0;
	m_nKeepAliveTime	= INFINITE;
	m_bPassiveMode		= FALSE;
	m_bDisconnectPending= FALSE;
	memset(&m_ComStatOld, 0, sizeof(COMSTAT));
	memset(&m_ComStatNew, 0, sizeof(COMSTAT));

#ifdef WINCE
	strDevice = pszDevice;
	m_hComPort = CreateFile(strDevice,
							GENERIC_READ | GENERIC_WRITE, 
							0, 
							0,
							OPEN_EXISTING,
							FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
							0);
#else
	m_hComPort = CreateFile(pszDevice,
							GENERIC_READ | GENERIC_WRITE, 
							0, 
							0,
							OPEN_EXISTING,
							FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
							0);
#endif

	if (m_hComPort == INVALID_HANDLE_VALUE)
    {
        XDEBUG("[CSerialServer] Invalid Handle Value\r\n");
		return FALSE;
    }

    // Save original comm timeouts and set new ones
    if (!GetCommTimeouts(m_hComPort, &m_timeoutOld))
		XDEBUG("[CSerialServer] GetCommTimeouts.\r\n");

    // Set Port State
    UpdateConnection();

    // Set comm buffer sizes
    SetupComm(m_hComPort, MAX_READ_BUFFER, MAX_WRITE_BUFFER);

    // Raise DTR
    if (!EscapeCommFunction(m_hComPort, SETDTR))
        XDEBUG("[CSerialServer] EscapeCommFunction (SETDTR).\r\n");

	StartThread();
	m_bConnected = TRUE;
	return TRUE;
}
Example #4
0
CNetManager::CNetManager()
{
	InitializeVariable();
}