⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 serversock.cpp

📁 模块化机器人远程控制客户端
💻 CPP
字号:
// ServerSock.cpp : implementation file
//

#include "stdafx.h"
#include "Server.h"
#include "ServerSock.h"
#include "ServerDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CServerSock

CServerSock::CServerSock()
{
}

CServerSock::~CServerSock()
{
}


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

/////////////////////////////////////////////////////////////////////////////
// CServerSock member functions

void CServerSock::OnAccept(int nErrorCode) 
{
	// TODO: Add your specialized code here and/or call the base class
	CNewSocket* pSocket=new CNewSocket();
	if (Accept(*pSocket)) {
		pSocket->AsyncSelect(FD_READ);
		m_pSocket=pSocket;
	}
	else
		delete pSocket;
	
	CAsyncSocket::OnAccept(nErrorCode);
}
/////////////////////////////////////////////////////////////////////////////
// CServerDataSock

CServerDataSock::CServerDataSock()
{
}

CServerDataSock::~CServerDataSock()
{
}


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

/////////////////////////////////////////////////////////////////////////////
// CServerDataSock member functions

void CServerDataSock::OnAccept(int nErrorCode) 
{
	// TODO: Add your specialized code here and/or call the base class
	CServerApp* pApp=(CServerApp*)AfxGetApp();
	CServerDlg* pDlg=(CServerDlg*)pApp->m_pMainWnd;
	
	CNewDataSocket* pDataSocket=new CNewDataSocket();
	if (Accept(*pDataSocket)) {
		pDataSocket->AsyncSelect(FD_READ);
		m_pDataSocket=pDataSocket;
		pDlg->m_bArray=TRUE;
	}
	else
		delete pDataSocket;
	
	CAsyncSocket::OnAccept(nErrorCode);
}
/////////////////////////////////////////////////////////////////////////////
// CServerBackDataSock

CServerBackDataSock::CServerBackDataSock()
{
}

CServerBackDataSock::~CServerBackDataSock()
{
}


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

/////////////////////////////////////////////////////////////////////////////
// CServerBackDataSock member functions

void CServerBackDataSock::OnAccept(int nErrorCode) 
{
	// TODO: Add your specialized code here and/or call the base class
	CNewBackDataSocket *pBackDataSocket=new CNewBackDataSocket();
	if (Accept(*pBackDataSocket)) {
		m_backDataSocket=pBackDataSocket;
	}
	else
		delete pBackDataSocket;	
	
	CAsyncSocket::OnAccept(nErrorCode);
}

⌨️ 快捷键说明

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