proctcpclientthread.cpp

来自「一个声讯平台的管理平台.包括平台的客户端何服务器端口.是个不错的软件.」· C++ 代码 · 共 134 行

CPP
134
字号
// ProcTcpClientThread.cpp : implementation file
//

#include "stdafx.h"
#include "IvrServer.h"
#include "ProcTcpClientThread.h"


#include "winbase.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CProcTcpClientThread
bool	iExit;
extern int iCountClient;
extern int iInterface;
extern int g_iTimeOut;
extern int bNeed;

IMPLEMENT_DYNCREATE(CProcTcpClientThread, CWinThread)

CProcTcpClientThread::CProcTcpClientThread()
{
}

CProcTcpClientThread::~CProcTcpClientThread()
{
}

BOOL CProcTcpClientThread::InitInstance()
{
	// TODO:  perform and per-thread initialization here
	return TRUE;
}

int CProcTcpClientThread::ExitInstance()
{
	// TODO:  perform any per-thread cleanup here
	return CWinThread::ExitInstance();
}

BEGIN_MESSAGE_MAP(CProcTcpClientThread, CWinThread)
	//{{AFX_MSG_MAP(CProcTcpClientThread)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CProcTcpClientThread message handlers

int CProcTcpClientThread::Run() 
{
	// TODO: Add your specialized code here and/or call the base class
	
	long iThreadTime = time(NULL);
/*
	while(iExit)
	{
		if (OnSelectSocket() > RETCODE_SUCCESS)
		{
			iStartTime = time(NULL);
			if (OnDoWith() == RETCODE_FAIL)
			{
				break;
			}

			if (strNew1 != NULL)
			{
				delete []strNew1;
				strNew1 = NULL;
			}

			if (strNew2 != NULL)
			{
				delete []strNew2;
				strNew2 = NULL;
			}
		}
		
		if (time(NULL) - iThreadTime > g_iTimeOut)
		{
			break;
		}
		Sleep(10);
	}

	if (strNew1 != NULL)
	{
		delete []strNew1;
		strNew1 = NULL;
	}

	if (strNew2 != NULL)
	{
		delete []strNew2;
		strNew2 = NULL;
	}

	iExit = false;

	closesocket(RemoteClientSocket);
	AfxEndThread(0);
*/
	return RETCODE_SUCCESS;


}

/***************************************************************
函数介绍:	检查是否有数据可读
输入参数:	
输出参数:	
函数返回:	>0成功; 否则失败.
***************************************************************/
int CProcTcpClientThread::OnSelectSocket()
{
	int				result;
	fd_set			fdset;
	struct timeval	tv;

	tv.tv_sec = 0;
    tv.tv_usec = 0;
   	FD_ZERO(&fdset);
	FD_SET(RemoteClientSocket, &fdset);
	result = select(RemoteClientSocket + 1, &fdset, NULL, NULL, &tv);
	return result;
}

⌨️ 快捷键说明

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