-
大小: 7.88MB文件類型: .rar金幣: 2下載: 0 次發(fā)布日期: 2023-10-05
- 語言: C/C++
- 標簽:
資源簡介
用CSocket實現(xiàn)的一個服務(wù)端和客戶端,服務(wù)端啟動后可以啟動監(jiān)聽,等待客戶端連接。當客戶端發(fā)來消息時,自動回發(fā)一個消息。客戶端發(fā)"close"可以使服務(wù)端停止監(jiān)聽,發(fā)"quit"可以使服務(wù)端delete監(jiān)聽線程,這樣服務(wù)端點擊“啟動監(jiān)聽”按鈕時,會重新創(chuàng)建監(jiān)聽線程并監(jiān)聽。

代碼片段和文件信息
//?ClientApp.cpp?:?Defines?the?class?behaviors?for?the?application.
//
#include?“stdafx.h“
#include?“ClientApp.h“
#include?“ClientAppDlg.h“
#ifdef?_DEBUG
#define?new?DEBUG_NEW
#undef?THIS_FILE
static?char?THIS_FILE[]?=?__FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
//?CClientAppApp
BEGIN_MESSAGE_MAP(CClientAppApp?CWinApp)
//{{AFX_MSG_MAP(CClientAppApp)
//?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()
/////////////////////////////////////////////////////////////////////////////
//?CClientAppApp?construction
CClientAppApp::CClientAppApp()
{
//?TODO:?add?construction?code?here
//?Place?all?significant?initialization?in?InitInstance
}
/////////////////////////////////////////////////////////////////////////////
//?The?one?and?only?CClientAppApp?object
CClientAppApp?theApp;
/////////////////////////////////////////////////////////////////////////////
//?CClientAppApp?initialization
BOOL?CClientAppApp::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
CClientAppDlg?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;
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????20996??2011-01-24?09:00??ClientApp\ClientApp.aps
?????文件???????1167??2011-02-22?10:08??ClientApp\ClientApp.clw
?????文件???????2199??2010-05-21?16:52??ClientApp\ClientApp.cpp
?????文件???????4214??2011-01-24?00:46??ClientApp\ClientApp.dsp
?????文件????????543??2011-01-23?17:04??ClientApp\ClientApp.dsw
?????文件???????1357??2010-05-21?16:52??ClientApp\ClientApp.h
?????文件?????107520??2011-02-22?18:01??ClientApp\ClientApp.ncb
?????文件??????53760??2011-02-22?18:01??ClientApp\ClientApp.opt
?????文件????????994??2011-02-22?08:54??ClientApp\ClientApp.plg
?????文件???????5363??2011-01-23?18:15??ClientApp\ClientApp.rc
?????文件???????4813??2011-02-22?08:53??ClientApp\ClientAppDlg.cpp
?????文件???????1423??2011-01-23?18:15??ClientApp\ClientAppDlg.h
?????文件????3695616??2011-01-23?23:21??ClientApp\Debug\ClientApp.bsc
?????文件?????106572??2011-02-22?08:54??ClientApp\Debug\ClientApp.exe
?????文件?????200220??2011-02-22?08:54??ClientApp\Debug\ClientApp.ilk
?????文件??????14463??2011-02-22?08:48??ClientApp\Debug\ClientApp.obj
?????文件????6948948??2011-02-22?08:48??ClientApp\Debug\ClientApp.pch
?????文件?????377856??2011-02-22?08:54??ClientApp\Debug\ClientApp.pdb
?????文件???????2588??2011-02-22?08:48??ClientApp\Debug\ClientApp.res
?????文件???????2600??2011-02-22?08:48??ClientApp\Debug\ClientApp.sbr
?????文件??????28524??2011-02-22?08:54??ClientApp\Debug\ClientAppDlg.obj
?????文件???????4855??2011-02-22?08:54??ClientApp\Debug\ClientAppDlg.sbr
?????文件?????106651??2011-02-22?08:48??ClientApp\Debug\StdAfx.obj
?????文件????1391428??2011-02-22?08:48??ClientApp\Debug\StdAfx.sbr
?????文件?????205824??2011-02-22?08:54??ClientApp\Debug\vc60.idb
?????文件?????364544??2011-02-22?08:54??ClientApp\Debug\vc60.pdb
?????文件????????258??2011-02-22?10:11??ClientApp\ReadMe.txt
?????文件???????1078??2010-05-21?16:52??ClientApp\res\ClientApp.ico
?????文件????????401??2010-05-21?16:52??ClientApp\res\ClientApp.rc2
?????文件????????870??2011-01-23?18:15??ClientApp\Resource.h
............此處省略56個文件信息
- 上一篇:先進PID控制MATLAB仿真
- 下一篇:算法精解:C語言描述(含源代碼)
評論
共有 條評論