lisent.cpp

来自「一个服务器端小软件,方便初学者了解基于服务器-客户端的工作原理」· C++ 代码 · 共 56 行

CPP
56
字号
// Lisent.cpp : implementation file
//

#include "stdafx.h"
#include "ServerNet.h"
#include "Lisent.h"

#include "Client.h"
#include "MainFrm.h"

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

/////////////////////////////////////////////////////////////////////////////
// CLisent

CLisent::CLisent(CMainFrame *pMainFrame)
{
	m_pMainFrame=pMainFrame;
}

CLisent::~CLisent()
{
}


// Do not edit the following lines, which are needed by ClassWizard.
#if 0
BEGIN_MESSAGE_MAP(CLisent, CSocket)
	//{{AFX_MSG_MAP(CLisent)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()
#endif	// 0

/////////////////////////////////////////////////////////////////////////////
// CLisent member functions

//利用ClassWizar生成下面的消息响应函数

void CLisent::OnAccept(int nErrorCode) 
{
	// TODO: Add your specialized code here and/or call the base class
	
	CClient *pSocket=new CClient(m_pMainFrame);
	if(m_pMainFrame->m_pListening->Accept(*pSocket))
	{
		m_pMainFrame->m_pList.AddTail(pSocket);
	}
	else 
		delete pSocket;
	CSocket::OnAccept(nErrorCode);
}

⌨️ 快捷键说明

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