示例#1
0
BOOL CIocpServer::Start(LPCTSTR pszBindAddress, USHORT usPort)
{
	if(!CheckParams() || !CheckStarting())
		return FALSE;

	//创建监听套接字开始监听端口
	if(CreateListenSocket(pszBindAddress, usPort))
	{
		if(CreateCompletePort())
		{
			if(CreateWorkerThreads())
			{
				if(StartAcceptThread())
				{
					m_enState = SS_STARTED;
					return TRUE;
				}
			}
		}
	}


	Stop();

	return FALSE;
}
示例#2
0
I2cPlugin::I2cPlugin(PluginInfo* pluginInfo) : PluginInterface(pluginInfo)
{
	I2c* tempDriver = new I2c();
	list<string*>* functionList = tempDriver->getAllFunctionNames();
	delete tempDriver;

	StartAcceptThread();
	if(wait_for_accepter_up() != 0)
		throw Error("Creation of Listener/worker threads failed.");

	pluginActive = true;

	regClient = new RegClient(pluginInfo, functionList, REG_PATH);
}