Example #1
0
DWORD CMMThread::StartThread(ST_THREADS_PARAM *pstThreadsParam)
{
	ST_THREADS_PARAM stThreadParam = *pstThreadsParam;

	ST_SERVER_ADDR stServerAddr;
	stServerAddr.strIPAddress = stThreadParam.strIPAddress;
	stServerAddr.dwPort = stThreadParam.dwPort;

	InitServerConnection(stServerAddr);

	BOOL bConnected = FALSE;
	BOOL bContinue = TRUE;
	while (bContinue) 
	{
		try
		{
			if (!bConnected) {
				bConnected = ConnectToServer();
			}

			ProcessCycleTask(stThreadParam);
		}
		catch (std::exception &e) {
			ErrorLog("%s", e.what());
			::WSACleanup();
		}

		// Wait for 1 second for a next step
		::Sleep(1000);
	}
	
	::WSACleanup();
	return E_RET_SUCCESS;
}
Example #2
0
extern "C" APIRET APIENTRY InitSrvConn(char *remotemachineName, ULONG *obj)
{
  int  rc;

  /* First  let's look for FreePM.ini and read it if any */
  FPM_config.Read("fpm.ini");

  if (remotemachineName)
  {
    strcpy(FPM_config.ExternMachineName, remotemachineName);
    ExternMachine = &FPM_config.ExternMachineName[0];
  } else {
    /* test for FreePM's semaphore  at local machine */

    HMTX    FREEPM_hmtx     = NULLHANDLE; /* Mutex semaphore handle */

    rc = DosOpenMutexSem(FREEPM_MUTEX_NAME,    /* Semaphore name */
                         &FREEPM_hmtx);        /* Handle returned */

    DosCloseMutexSem(FREEPM_hmtx);

    if (rc)
      /* FreePM server is not running at local machine, let's look for FreePM.ini */
      ExternMachine = &FPM_config.ExternMachineName[0];
    else
      ExternMachine = NULL;
  }

  /* init connection to FreePM server */
  rc = InitServerConnection(ExternMachine, obj);

  if (rc && ExternMachine)
  {
     ExecuteFreePMServer();
     DosSleep(1000);
     rc = InitServerConnection(NULL, obj);
  }

  return rc;
}
Example #3
0
void NXConnection::Start()
{
#if defined(WIN32)
	// Start the X Server
  pXServer = CreateXServerConnection( pSession );
  if( InitXServerConnection( pXServer ) == NX_Exception )
  {
    NX_LOG_LOGERROR("Cannot init XServer.\n" );
       return;
  }
else
   {
    if( AdvanceXServerConnection( pXServer ) == NX_Exception )
    {
      NX_LOG_LOGERROR("XServer cannot start.\n" );
	  return;
    }
}
	
#endif
  pConnection = CreateServerConnection( pSession, "nxssh" );
  if( pConnection )
    InitServerConnection( pConnection );
}