listenthread.cpp

来自「LINUX 线程池源代码:Lock.cpp : 锁的操作 , 读锁可以」· C++ 代码 · 共 50 行

CPP
50
字号
#include "ListenThread.h"#include "Log.h"G_ListenThread::G_ListenThread(G_ThreadPool *pool) : g_threadPool(pool){	g_socket = new G_Socket();}G_ListenThread::~G_ListenThread(){	if(g_socket)	{		delete g_socket;		g_socket = NULL;	}}void G_ListenThread::Run(){	pause();	debug_output("Listen thread is starting ....\n");		int nSocket; 	while(1)	{		if(g_socket->Listen(nSocket))		{			debug_output("new client is connecting ....\n");			g_threadPool->pushSocket(nSocket);   ///填加到套接口队列			g_threadPool->continues();   ///通知线程池,运行起来,到套接口队列中取套接口		}	}}bool G_ListenThread::Bind(unsigned int nPort){	if(!g_socket->Bind(nPort))	{		debug_output("Bind port %d is faild\n" , nPort);		return false;	}	debug_output("Bind port %d is Successful\n" , nPort);	continues();	return true;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?