資源簡介
單界面,在界面內可以選擇是服務端還是客戶端,先運行服務端,點擊監聽按鈕,與客戶端連接成功后可以通信。未使用到多線程技術,代碼段都有注釋,適合初學者。

代碼片段和文件信息
//?MySock.cpp?:?Defines?the?class?behaviors?for?the?application.
//
#include?“stdafx.h“
#include?“MySock.h“
#include?“MySockDlg.h“
#ifdef?_DEBUG
#define?new?DEBUG_NEW
#undef?THIS_FILE
static?char?THIS_FILE[]?=?__FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
//?CMySockApp
BEGIN_MESSAGE_MAP(CMySockApp?CWinApp)
//{{AFX_MSG_MAP(CMySockApp)
//?NOTE?-?the?ClassWizard?will?add?and?remove?mapping?macros?here.
//????DO?NOT?EDIT?what?you?see?in?these?blocks?of?generated?code!
//}}AFX_MSG
ON_COMMAND(ID_HELP?CWinApp::onhelp)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
//?CMySockApp?construction
CMySockApp::CMySockApp()
{
//?TODO:?add?construction?code?here
//?Place?all?significant?initialization?in?InitInstance
}
/////////////////////////////////////////////////////////////////////////////
//?The?one?and?only?CMySockApp?object
CMySockApp?theApp;
/////////////////////////////////////////////////////////////////////////////
//?CMySockApp?initialization
BOOL?CMySockApp::InitInstance()
{
if?(!AfxSocketInit())
{
AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
return?FALSE;
}
AfxEnableControlContainer();
//?Standard?initialization
//?If?you?are?not?using?these?features?and?wish?to?reduce?the?size
//??of?your?final?executable?you?should?remove?from?the?following
//??the?specific?initialization?routines?you?do?not?need.
#ifdef?_AFXDLL
Enable3dControls(); //?Call?this?when?using?MFC?in?a?shared?DLL
#else
Enable3dControlsStatic(); //?Call?this?when?linking?to?MFC?statically
#endif
CMySockDlg?dlg;
m_pMainWnd?=?&dlg;
int?nResponse?=?dlg.DoModal();
if?(nResponse?==?IDOK)
{
//?TODO:?Place?code?here?to?handle?when?the?dialog?is
//??dismissed?with?OK
}
else?if?(nResponse?==?IDCANCEL)
{
//?TODO:?Place?code?here?to?handle?when?the?dialog?is
//??dismissed?with?Cancel
}
//?Since?the?dialog?has?been?closed?return?FALSE?so?that?we?exit?the
//??application?rather?than?start?the?application‘s?message?pump.
return?FALSE;
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2015-04-26?14:59??MySock\
?????目錄???????????0??2015-04-26?14:59??MySock\Debug\
?????文件??????114731??2015-04-26?14:59??MySock\Debug\MySock.exe
?????文件??????230340??2015-04-26?14:59??MySock\Debug\MySock.ilk
?????文件???????15547??2015-04-26?14:35??MySock\Debug\MySock.obj
?????文件?????5563788??2015-04-26?12:56??MySock\Debug\MySock.pch
?????文件??????369664??2015-04-26?14:59??MySock\Debug\MySock.pdb
?????文件????????3100??2015-04-26?14:59??MySock\Debug\MySock.res
?????文件???????39394??2015-04-26?14:35??MySock\Debug\MySockDlg.obj
?????文件????????6101??2015-04-26?14:35??MySock\Debug\MySocket.obj
?????文件??????106366??2015-04-26?12:56??MySock\Debug\StdAfx.obj
?????文件??????214016??2015-04-26?14:59??MySock\Debug\vc60.idb
?????文件??????372736??2015-04-26?14:35??MySock\Debug\vc60.pdb
?????文件???????36392??2015-04-26?14:59??MySock\MySock.aps
?????文件????????1849??2015-04-26?14:59??MySock\MySock.clw
?????文件????????2157??2015-04-26?12:42??MySock\MySock.cpp
?????文件????????4287??2015-04-26?14:36??MySock\MySock.dsp
?????文件?????????518??2015-04-26?12:42??MySock\MySock.dsw
?????文件????????1324??2015-04-26?12:42??MySock\MySock.h
?????文件???????50176??2015-04-26?14:59??MySock\MySock.ncb
?????文件???????48640??2015-04-26?14:59??MySock\MySock.opt
?????文件?????????680??2015-04-26?14:59??MySock\MySock.plg
?????文件????????6372??2015-04-26?14:59??MySock\MySock.rc
?????文件????????8142??2015-04-26?13:25??MySock\MySockDlg.cpp
?????文件????????1724??2015-04-26?13:22??MySock\MySockDlg.h
?????文件????????2037??2015-04-26?14:35??MySock\MySocket.cpp
?????文件????????1866??2015-04-26?14:35??MySock\MySocket.h
?????文件????????3579??2015-04-26?12:42??MySock\ReadMe.txt
?????文件?????????208??2015-04-26?12:42??MySock\StdAfx.cpp
?????文件????????1102??2015-04-26?12:42??MySock\StdAfx.h
?????目錄???????????0??2015-04-26?12:42??MySock\res\
............此處省略3個文件信息
- 上一篇:開源H.264碼流分析器程序+源代碼
- 下一篇:visual c++14.0
評論
共有 條評論