资源简介

用VS2010编写的网络文件传输软件,对于网络编程初学者有一定学习作用

资源截图

代码片段和文件信息

// ClientSocket.cpp : 实现文件
//

#include “stdafx.h“
#include “FileTransNet.h“
#include “ClientSocket.h“

#include “FileTransNetDlg.h“
// CClientSocket

CClientSocket::CClientSocket(CFileTransNetDlg* 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()
{
}


// CClientSocket 成员函数
//串行化的初始化
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)
{
// TODO: 在此添加专用代码和/或调用基类
m_pdlgMain->ProcessReceive(this);
CSocket::OnReceive(nErrorCode);
}


void CClientSocket::OnClose(int nErrorCode)
{
// TODO: 在此添加专用代码和/或调用基类
m_pdlgMain->ProcessClose();
CSocket::OnClose(nErrorCode);
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件    1503184  2012-12-04 00:53  FileTransNet\Debug\FileTransNet.ilk

     文件    5295104  2012-12-04 00:53  FileTransNet\Debug\FileTransNet.pdb

     文件       1631  2012-12-03 10:09  FileTransNet\FileTransNet\ClientSocket.cpp

     文件        601  2012-12-03 10:09  FileTransNet\FileTransNet\ClientSocket.h

     文件      35812  2012-12-04 00:06  FileTransNet\FileTransNet\FileTransNet.aps

     文件       2165  2012-12-01 13:27  FileTransNet\FileTransNet\FileTransNet.cpp

     文件        476  2012-12-01 14:18  FileTransNet\FileTransNet\FileTransNet.h

     文件      13348  2012-12-04 00:03  FileTransNet\FileTransNet\FileTransNet.rc

     文件       6305  2012-12-04 00:02  FileTransNet\FileTransNet\FileTransNet.vcxproj

     文件       2760  2012-12-04 00:02  FileTransNet\FileTransNet\FileTransNet.vcxproj.filters

     文件        143  2012-12-01 13:27  FileTransNet\FileTransNet\FileTransNet.vcxproj.user

     文件      27759  2012-12-04 00:53  FileTransNet\FileTransNet\FileTransNetDlg.cpp

     文件       3017  2012-12-03 22:38  FileTransNet\FileTransNet\FileTransNetDlg.h

     文件        552  2012-12-01 14:04  FileTransNet\FileTransNet\ListenSocket.cpp

     文件        307  2012-12-02 12:32  FileTransNet\FileTransNet\ListenSocket.h

     文件        841  2012-12-01 13:31  FileTransNet\FileTransNet\Message.cpp

     文件        318  2012-12-01 13:31  FileTransNet\FileTransNet\Message.h

     文件       3167  2012-12-01 13:27  FileTransNet\FileTransNet\ReadMe.txt

     文件        680  2012-12-01 13:27  FileTransNet\FileTransNet\res\FileTransNet.rc2

     文件       1078  2012-12-02 12:49  FileTransNet\FileTransNet\res\ICON_NOT.ICO

     文件       1078  2012-12-02 12:49  FileTransNet\FileTransNet\res\ICON_ON.ICO

     文件       9662  2012-12-04 00:42  FileTransNet\FileTransNet\res\Myself.ico

     文件       4124  2012-12-04 00:01  FileTransNet\FileTransNet\resource.h

     文件        145  2012-12-01 13:27  FileTransNet\FileTransNet\stdafx.cpp

     文件       1699  2012-12-01 14:06  FileTransNet\FileTransNet\stdafx.h

     文件        234  2012-12-01 13:27  FileTransNet\FileTransNet\targetver.h

     文件        903  2012-12-01 13:27  FileTransNet\FileTransNet.sln

    ..A..H.     38912  2013-01-21 22:15  FileTransNet\FileTransNet.suo

     文件    4639744  2012-12-04 00:53  FileTransNet\Release\FileTransNet.pdb

     目录          0  2013-02-22 22:59  FileTransNet\FileTransNet\res

............此处省略9个文件信息

评论

共有 条评论