資源簡介
該聊天室是基于TCP。程序分為兩個部分,客戶端和服務器端,利用Socket(套接字)編程,實現了多個客戶端之間的簡單通信。該程序是學習網絡編程的最佳選擇,它能幫助你迅速的掌握網絡編程的思路。

代碼片段和文件信息
//?ChatRoom_TCP_Client.cpp?:?定義應用程序的類行為。
//
#include?“stdafx.h“
#include?“ChatRoom_TCP_Client.h“
#include?“ChatRoom_TCP_ClientDlg.h“
#ifdef?_DEBUG
#define?new?DEBUG_NEW
#endif
//?CChatRoom_TCP_ClientApp
BEGIN_MESSAGE_MAP(CChatRoom_TCP_ClientApp?CWinApp)
ON_COMMAND(ID_HELP?&CWinApp::onhelp)
END_MESSAGE_MAP()
//?CChatRoom_TCP_ClientApp?構造
CChatRoom_TCP_ClientApp::CChatRoom_TCP_ClientApp()
{
//?支持重新啟動管理器
m_dwRestartManagerSupportFlags?=?AFX_RESTART_MANAGER_SUPPORT_RESTART;
//?TODO:?在此處添加構造代碼,
//?將所有重要的初始化放置在?InitInstance?中
}
//?唯一的一個?CChatRoom_TCP_ClientApp?對象
CChatRoom_TCP_ClientApp?theApp;
//?CChatRoom_TCP_ClientApp?初始化
BOOL?CChatRoom_TCP_ClientApp::InitInstance()
{
//?如果一個運行在?Windows?XP?上的應用程序清單指定要
//?使用?ComCtl32.dll?版本?6?或更高版本來啟用可視化方式,
//則需要?InitCommonControlsEx()。否則,將無法創建窗口。
INITCOMMONCONTROLSEX?InitCtrls;
InitCtrls.dwSize?=?sizeof(InitCtrls);
//?將它設置為包括所有要在應用程序中使用的
//?公共控件類。
InitCtrls.dwICC?=?ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);
CWinApp::InitInstance();
if?(!AfxSocketInit())
{
AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
return?FALSE;
}
AfxEnableControlContainer();
//?創建?shell?管理器,以防對話框包含
//?任何?shell?樹視圖控件或?shell?列表視圖控件。
CShellManager?*pShellManager?=?new?CShellManager;
//?標準初始化
//?如果未使用這些功能并希望減小
//?最終可執行文件的大小,則應移除下列
//?不需要的特定初始化例程
//?更改用于存儲設置的注冊表項
//?TODO:?應適當修改該字符串,
//?例如修改為公司或組織名
SetRegistryKey(_T(“應用程序向導生成的本地應用程序“));
CChatRoom_TCP_ClientDlg?dlg;
m_pMainWnd?=?&dlg;
INT_PTR?nResponse?=?dlg.DoModal();
if?(nResponse?==?IDOK)
{
//?TODO:?在此放置處理何時用
//??“確定”來關閉對話框的代碼
}
else?if?(nResponse?==?IDCANCEL)
{
//?TODO:?在此放置處理何時用
//??“取消”來關閉對話框的代碼
}
//?刪除上面創建的?shell?管理器。
if?(pShellManager?!=?NULL)
{
delete?pShellManager;
}
//?由于對話框已關閉,所以將返回?FALSE?以便退出應用程序,
//??而不是啟動應用程序的消息泵。
return?FALSE;
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????106868??2013-07-03?10:47??TCP_Chat\ChatRoom_TCP_Client\ChatRoom_TCP_Client\ChatRoom_TCP_Client.aps
?????文件???????2256??2013-07-03?09:01??TCP_Chat\ChatRoom_TCP_Client\ChatRoom_TCP_Client\ChatRoom_TCP_Client.cpp
?????文件????????520??2013-07-03?09:01??TCP_Chat\ChatRoom_TCP_Client\ChatRoom_TCP_Client\ChatRoom_TCP_Client.h
?????文件??????11932??2013-07-03?10:47??TCP_Chat\ChatRoom_TCP_Client\ChatRoom_TCP_Client\ChatRoom_TCP_Client.rc
?????文件???????6117??2013-07-03?09:08??TCP_Chat\ChatRoom_TCP_Client\ChatRoom_TCP_Client\ChatRoom_TCP_Client.vcxproj
?????文件???????2262??2013-07-03?09:08??TCP_Chat\ChatRoom_TCP_Client\ChatRoom_TCP_Client\ChatRoom_TCP_Client.vcxproj.filters
?????文件????????143??2013-07-03?09:01??TCP_Chat\ChatRoom_TCP_Client\ChatRoom_TCP_Client\ChatRoom_TCP_Client.vcxproj.user
?????文件???????7298??2013-07-03?15:47??TCP_Chat\ChatRoom_TCP_Client\ChatRoom_TCP_Client\ChatRoom_TCP_ClientDlg.cpp
?????文件???????1042??2013-07-03?10:22??TCP_Chat\ChatRoom_TCP_Client\ChatRoom_TCP_Client\ChatRoom_TCP_ClientDlg.h
?????文件????????543??2013-07-03?15:38??TCP_Chat\ChatRoom_TCP_Client\ChatRoom_TCP_Client\ClientSocket.cpp
?????文件????????353??2013-07-03?13:37??TCP_Chat\ChatRoom_TCP_Client\ChatRoom_TCP_Client\ClientSocket.h
?????文件???????3300??2013-07-03?09:01??TCP_Chat\ChatRoom_TCP_Client\ChatRoom_TCP_Client\ReadMe.txt
?????文件??????67777??2009-08-31?02:31??TCP_Chat\ChatRoom_TCP_Client\ChatRoom_TCP_Client\res\ChatRoom_TCP_Client.ico
?????文件????????694??2013-07-03?09:01??TCP_Chat\ChatRoom_TCP_Client\ChatRoom_TCP_Client\res\ChatRoom_TCP_Client.rc2
?????文件???????2302??2013-07-03?10:47??TCP_Chat\ChatRoom_TCP_Client\ChatRoom_TCP_Client\resource.h
?????文件????????152??2013-07-03?09:01??TCP_Chat\ChatRoom_TCP_Client\ChatRoom_TCP_Client\stdafx.cpp
?????文件???????1683??2013-07-03?09:01??TCP_Chat\ChatRoom_TCP_Client\ChatRoom_TCP_Client\stdafx.h
?????文件????????234??2013-07-03?09:01??TCP_Chat\ChatRoom_TCP_Client\ChatRoom_TCP_Client\targetver.h
?????文件????????924??2013-07-03?09:01??TCP_Chat\ChatRoom_TCP_Client\ChatRoom_TCP_Client.sln
????..A..H.?????17408??2013-07-03?16:29??TCP_Chat\ChatRoom_TCP_Client\ChatRoom_TCP_Client.suo
?????文件?????106768??2013-07-03?14:13??TCP_Chat\ChatRoom_TCP_Server\ChatRoom_TCP_Server\ChatRoom_TCP_Server.aps
?????文件???????2256??2013-07-02?10:21??TCP_Chat\ChatRoom_TCP_Server\ChatRoom_TCP_Server\ChatRoom_TCP_Server.cpp
?????文件????????520??2013-07-02?10:21??TCP_Chat\ChatRoom_TCP_Server\ChatRoom_TCP_Server\ChatRoom_TCP_Server.h
?????文件??????11844??2013-07-03?14:13??TCP_Chat\ChatRoom_TCP_Server\ChatRoom_TCP_Server\ChatRoom_TCP_Server.rc
?????文件???????6299??2013-07-02?16:38??TCP_Chat\ChatRoom_TCP_Server\ChatRoom_TCP_Server\ChatRoom_TCP_Server.vcxproj
?????文件???????2644??2013-07-02?16:38??TCP_Chat\ChatRoom_TCP_Server\ChatRoom_TCP_Server\ChatRoom_TCP_Server.vcxproj.filters
?????文件????????143??2013-07-02?10:20??TCP_Chat\ChatRoom_TCP_Server\ChatRoom_TCP_Server\ChatRoom_TCP_Server.vcxproj.user
?????文件???????6395??2013-07-03?15:00??TCP_Chat\ChatRoom_TCP_Server\ChatRoom_TCP_Server\ChatRoom_TCP_ServerDlg.cpp
?????文件???????1158??2013-07-02?20:56??TCP_Chat\ChatRoom_TCP_Server\ChatRoom_TCP_Server\ChatRoom_TCP_ServerDlg.h
?????文件??????????0??2013-07-02?10:52??TCP_Chat\ChatRoom_TCP_Server\ChatRoom_TCP_Server\ClistenSocket.cpp
............此處省略36個文件信息
- 上一篇:net讀取表格word
- 下一篇:博圖v13授權文件
評論
共有 條評論