資源簡介
本程序基于windows的異步消息機制,采用異步套接字WSAsoket,詳細設計實現了客戶端、服務器端的即時消息通訊,是做聊天室(單人聊天、多人聊天)的一個很好的例子,編程工具采用VC++(MFC),希望對有此方面需求的廣大編程愛好者提供很好的參考。。
代碼片段和文件信息
//?client.cpp?:?Defines?the?class?behaviors?for?the?application.
//
#include?“stdafx.h“
#include?“client.h“
#include?“clientDlg.h“
#ifdef?_DEBUG
#define?new?DEBUG_NEW
#undef?THIS_FILE
static?char?THIS_FILE[]?=?__FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
//?CClientApp
BEGIN_MESSAGE_MAP(CClientApp?CWinApp)
//{{AFX_MSG_MAP(CClientApp)
//?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()
/////////////////////////////////////////////////////////////////////////////
//?CClientApp?construction
CClientApp::CClientApp()
{
//?TODO:?add?construction?code?here
//?Place?all?significant?initialization?in?InitInstance
}
/////////////////////////////////////////////////////////////////////////////
//?The?one?and?only?CClientApp?object
CClientApp?theApp;
/////////////////////////////////////////////////////////////////////////////
//?CClientApp?initialization
BOOL?CClientApp::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
CClientDlg?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;
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????36048??2004-10-11?13:53??WSAsocket-serverclient\client\client.aps
?????文件???????1311??2004-10-11?14:29??WSAsocket-serverclient\client\client.clw
?????文件???????2157??2004-09-30?13:06??WSAsocket-serverclient\client\client.cpp
?????文件???????4390??2004-10-11?13:38??WSAsocket-serverclient\client\client.dsp
?????文件????????535??2004-09-30?13:06??WSAsocket-serverclient\client\client.dsw
?????文件???????1324??2004-09-30?13:06??WSAsocket-serverclient\client\client.h
?????文件??????66560??2004-10-27?18:16??WSAsocket-serverclient\client\client.ncb
?????文件??????53760??2004-10-27?18:16??WSAsocket-serverclient\client\client.opt
?????文件???????1808??2004-10-27?18:16??WSAsocket-serverclient\client\client.plg
?????文件???????5716??2004-10-11?13:53??WSAsocket-serverclient\client\client.rc
?????文件???????7085??2004-10-11?14:14??WSAsocket-serverclient\client\clientDlg.cpp
?????文件???????1862??2004-10-11?13:53??WSAsocket-serverclient\client\clientDlg.h
?????文件????????691??2004-10-11?13:39??WSAsocket-serverclient\client\MySocket.cpp
?????文件????????748??2004-10-11?13:39??WSAsocket-serverclient\client\MySocket.h
?????文件???????3579??2004-09-30?13:06??WSAsocket-serverclient\client\ReadMe.txt
?????文件???????1078??2004-09-30?13:06??WSAsocket-serverclient\client\res\client.ico
?????文件????????398??2004-09-30?13:06??WSAsocket-serverclient\client\res\client.rc2
?????文件????????959??2004-10-11?13:52??WSAsocket-serverclient\client\resource.h
?????文件????????208??2004-09-30?13:06??WSAsocket-serverclient\client\StdAfx.cpp
?????文件???????1134??2004-10-11?13:37??WSAsocket-serverclient\client\StdAfx.h
?????文件??????35968??2004-11-10?09:29??WSAsocket-serverclient\ClientTest\ClientTest.aps
?????文件???????1336??2004-11-10?09:29??WSAsocket-serverclient\ClientTest\ClientTest.clw
?????文件???????2119??2004-11-10?09:23??WSAsocket-serverclient\ClientTest\ClientTest.cpp
?????文件???????4231??2004-11-10?09:23??WSAsocket-serverclient\ClientTest\ClientTest.dsp
?????文件????????545??2004-11-10?09:23??WSAsocket-serverclient\ClientTest\ClientTest.dsw
?????文件???????1368??2004-11-10?09:23??WSAsocket-serverclient\ClientTest\ClientTest.h
?????文件??????41984??2004-11-10?09:29??WSAsocket-serverclient\ClientTest\ClientTest.ncb
?????文件??????48640??2004-11-10?09:29??WSAsocket-serverclient\ClientTest\ClientTest.opt
?????文件???????1693??2004-11-10?09:29??WSAsocket-serverclient\ClientTest\ClientTest.plg
?????文件???????5709??2004-11-10?09:29??WSAsocket-serverclient\ClientTest\ClientTest.rc
............此處省略59個文件信息
評論
共有 條評論