当前位置: 首页>>代码示例>>C++>>正文


C++ HttpServer::stop方法代码示例

本文整理汇总了C++中HttpServer::stop方法的典型用法代码示例。如果您正苦于以下问题:C++ HttpServer::stop方法的具体用法?C++ HttpServer::stop怎么用?C++ HttpServer::stop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HttpServer的用法示例。


在下文中一共展示了HttpServer::stop方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetTickCount

void CP2PServiceModule::OnCheckTimer( UINT uID, UINT uTime )
{
	if ( !g_socketClientMgr.IsConnected())
	{
		CKLog::WriteLog( LOG_TYPE_DEBUG, "reconnect server.%d", GetTickCount());
		g_server.stop();
		g_socketClientMgr.Release();
		if ( g_socketClientMgr.Connect())
			g_server.start();
	}
}
开发者ID:340211173,项目名称:P2PCenter,代码行数:11,代码来源:P2PService.cpp

示例2: CtrlHandler

BOOL CtrlHandler(DWORD fdwCtrlType)
{
	HttpServer* server;
	switch (fdwCtrlType)
	{
		// Handle the CTRL-C signal. 
	case CTRL_C_EVENT:
		LOG(INFO) << "The user wants to close server.";
		// shutdown server
		server = (HttpServer*)MainObjectFactoryImpl::getInstance()->getObject("HttpServer");
		if (server != NULL){
			server->stop();
		}
		else{
			LOG(WARNING) << "Failed to get server instance from factory.";
		}
		return(TRUE);

		// CTRL-CLOSE: confirm that the user wants to exit. 
		//case CTRL_CLOSE_EVENT:
		//	// shutdown server
		//	if (server != NULL){
		//		server->stop();
		//	}
		//	return(TRUE);

		//	// Pass other signals to the next handler. 
		//case CTRL_BREAK_EVENT:
		//	Beep(900, 200);
		//	printf("Ctrl-Break event\n\n");
		//	return FALSE;

		//case CTRL_LOGOFF_EVENT:
		//	Beep(1000, 200);
		//	printf("Ctrl-Logoff event\n\n");
		//	return FALSE;

		//case CTRL_SHUTDOWN_EVENT:
		//	Beep(750, 500);
		//	printf("Ctrl-Shutdown event\n\n");
		//	return FALSE;

	default:
		return FALSE;
	}
}
开发者ID:newton449,项目名称:virtual-server,代码行数:46,代码来源:MainProgram_Windows.cpp

示例3: defined

void CP2PServiceModule::RunMessageLoop()   
{    
#if defined(_DEBUG)
	_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
	CKLog::SetDebugType( LOG_TYPE_DEBUG);
#else
	CKLog::SetDebugType( LOG_TYPE_WARNING);
#endif

	char szServiceName[256];
	::LoadString( NULL, IDS_SERVICENAME, szServiceName, sizeof(szServiceName));
	ChangeServiceStartType( szServiceName, SERVICE_AUTO_START);

	TCHAR szClient_Mutex[] = _T("PPVOD_MUTEX_K_1.0");
	if ( ::OpenMutex(MUTEX_ALL_ACCESS, FALSE, szClient_Mutex) ) return;
	::CreateMutex(0, FALSE, szClient_Mutex);

	g_socketClientMgr.Connect();

	bool bListen = false;
	UINT uPort = 81;

	for ( int i = 1; i < 20; i ++ )
	{
		g_server.setPort( uPort);
		if ( g_server.create( string("P2PLocalService"), string("C:\\") ) )
		{
			bListen = true;
			break;
		}
		uPort += i;
	}

	HttpResponse::setServer( g_server );

	if ( bListen )
	{
		// 设置共享内存监听端口为 uPort
		CRegKey reg;
		LPCTSTR lpszKey = "SOFTWARE\\P2PService_K";

		if ( reg.Open( HKEY_LOCAL_MACHINE, lpszKey ) == ERROR_SUCCESS )
		{
			TCHAR szAppPath[MAX_PATH];
			ULONG ulLen = sizeof( szAppPath );
			if ( reg.SetDWORDValue( "ListenPort", uPort ) == ERROR_SUCCESS )
			{
			}
			reg.Close();
		}

		SetTimer( NULL, CHECK_SERVER_TIMER, 1000, NULL);

		MSG msg;
		while( GetMessage(&msg, NULL, 0, 0 )) 
		{
			switch( msg.message) {
			case WM_TIMER:
				OnCheckTimer( 0, 0);
				break;
			default:
				break;
			}
			TranslateMessage(&msg); 
			DispatchMessage(&msg); 
		}

		KillTimer( NULL, CHECK_SERVER_TIMER);
	}

	g_server.stop();

	SetServiceStatus(SERVICE_STOPPED);
}  
开发者ID:340211173,项目名称:P2PCenter,代码行数:74,代码来源:P2PService.cpp


注:本文中的HttpServer::stop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。