📄 recvsocket.cpp
字号:
// RecvSocket.cpp : implementation file
//
#include "stdafx.h"
#include "Receiver.h"
#include "RecvSocket.h"
#include "MainFrm.h"
#include "ReceiverDoc.h"
#include "ReceiverView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CRecvSocket
CRecvSocket::CRecvSocket()
{
}
CRecvSocket::~CRecvSocket()
{
}
// Do not edit the following lines, which are needed by ClassWizard.
#if 0
BEGIN_MESSAGE_MAP(CRecvSocket, CAsyncSocket)
//{{AFX_MSG_MAP(CRecvSocket)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
#endif // 0
/////////////////////////////////////////////////////////////////////////////
// CRecvSocket member functions
void CRecvSocket::OnClose(int nErrorCode)
{
// 关闭套接字
Close();
// 显示信息
CReceiverView* pView = (CReceiverView*)((CMainFrame*)AfxGetApp()->m_pMainWnd)->GetActiveView();
pView->m_listData.AddString("客机断开连接");
CAsyncSocket::OnClose(nErrorCode);
}
void CRecvSocket::OnReceive(int nErrorCode)
{
char buf[1024];
memset(buf, 0, sizeof(buf));
// 接收数据
Receive(buf, 1024);
// 显示信息
CReceiverView* pView = (CReceiverView*)((CMainFrame*)AfxGetApp()->m_pMainWnd)->GetActiveView();
pView->m_listData.AddString(CString(buf));
CAsyncSocket::OnReceive(nErrorCode);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -