资源简介
基于CSocket的局域网聊天和文件传输.7z
代码片段和文件信息
// ClientSocket.cpp : implementation file
//
#include “stdafx.h“
#include “TransferDemo.h“
#include “ClientSocket.h“
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CClientSocket
CClientSocket::CClientSocket(CTransferDemoDlg* pdlgMain)
{
m_pdlgMain = pdlgMain;
m_pFile = NULL;
m_pArchiveIn = NULL;
m_pArchiveOut = NULL;
}
CClientSocket::CClientSocket()
{
m_pdlgMain = NULL;
m_pFile = NULL;
m_pArchiveIn = NULL;
m_pArchiveOut = NULL;
}
CClientSocket::~CClientSocket()
{
}
// Do not edit the following lines which are needed by ClassWizard.
#if 0
BEGIN_MESSAGE_MAP(CClientSocket CSocket)
//{{AFX_MSG_MAP(CClientSocket)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
#endif // 0
/////////////////////////////////////////////////////////////////////////////
// CClientSocket member functions
//串行化的初始化
void CClientSocket::Init()
{
m_pFile = new CSocketFile(this);
m_pArchiveIn = new CArchive(m_pFileCArchive::load);
m_pArchiveOut = new CArchive(m_pFileCArchive::store);
}
void CClientSocket::Abort()
{
if (m_pArchiveOut != NULL)
{
m_pArchiveOut->Abort();
delete m_pArchiveOut;
m_pArchiveOut = NULL;
}
}
BOOL CClientSocket::SendMsg(CMessage *pMsg)
{
if (m_pArchiveOut != NULL)
{
TRY
{
pMsg->Serialize(*m_pArchiveOut);
m_pArchiveOut->Flush();
return TRUE;
}
CATCH(CFileException e)
{
m_pArchiveOut->Abort();
delete m_pArchiveOut;
m_pArchiveOut = NULL;
}
END_CATCH
}
return FALSE;
}
void CClientSocket::ReceiveMsg(CMessage *pMsg)
{
pMsg->Serialize(*m_pArchiveIn);
}
void CClientSocket::OnReceive(int nErrorCode)
{
m_pdlgMain->ProcessReceive(this);
CSocket::OnReceive(nErrorCode);
}
相关资源
- mybatis_plus_2.86_crack.zip
- 全网VIP视频电影免费看片神器V4.3.40微
- tesseract-3.04.00.tar.gz
- log_verilog.rar
- AMOS.zip
- 泛在电力物联网建设大纲.pptx
- 阿里云大数据专业认证ACP级-题库-完整
- 2019中科院最新SCI分区表.xls
- YJ_1.5_XiaZaiBa.zip
- dashufacescan.rar
- buck_boost小信号建模.zip
- 资源在这.docx
- 小龙成长记
- 运行Openair代码说明文档.pdf
- 单周期源码.zip
- GBT6323-2014汽车操纵稳定性试验方法.
- http_post.zip
- 万能客服15.2pc.rar
- 基于位置指纹的WiFi室内定位技术与实
- 牛客前端校招文档.pdf
- Activiti工作流课程.doc
- 喜鹊相亲交友平台V2.1.2.zip
- qq_29471575_10307979.zip
- HighText.rar
- 模仿12306火车票APP(微信小程序源代码
- 802.15.4-中文版前5章.pdf
- kids_1987_11127943.pdf
- SmsDemo.rar
- CoolTrayIcon任务栏图标cyrj2009改进版.r
- 第4章_家教信息平台.rar
评论
共有 条评论