Exemple #1
0
void * ThreadPool::work(void *p)
{
	ThreadPool* pool = (ThreadPool*)p;
	
	int fd = 0;
	while(1)
	{cout << "test\n";
		fd = 0;
		while(!fd)
		{
			cout << "pth_id" << pthread_self() << endl;
			fd = pool->m_socketList.pop();

		}
		//接收请求

		
		CSockApi cs(fd);
		CNotify notify;
		cs.receive_notify(notify);
		

		studentInfo stu;
		stu = *(studentInfo*)notify.get_data(&stu);
		
		LOG_DEBUG("sockid:%d",fd);
		LOG_ERROR("id:%d\nname:%s",stu.m_id,stu.m_name);
		//SQL sql;
		//sql.Connect();

		sleep(2);
		//sql.Insert(buf+16);
	}
	return pool;
}//线程函数
Exemple #2
0
int CSockApi::receive_notify(CNotify& pNotify)
{
	readN((char*)&pNotify,16);
	pNotify.n2h();
	pNotify.resize(pNotify.get_len());
	char *pdata = pNotify.get_data();
	return readN(pdata,pNotify.get_len());
	
}