資源簡介
學習過程當中的小實驗~使用時,任選一個運行的終端作為服務器,其余的用戶終端都在這個服務器的協調下交換信息
代碼片段和文件信息
//?ClientSocket.cpp?:?實現文件
//
#include?“stdafx.h“
#include?“SelfChat.h“
#include?“ClientSocket.h“
#include?“SelfChatDlg.h“
#include?“tagHeader.h“
void?ClientSocket::GetDlg(CSelfChatDlg?*dlg) //獲得窗口界面的指針
{
????chatDlg?=?dlg;
}
//?ClientSocket
ClientSocket::ClientSocket()
{
}
ClientSocket::~ClientSocket()
{
}
void?ClientSocket::OnReceive(int?nErrorCode)
{
????char?buff[sizeof(Header)];
????memset(buff0sizeof(buff));
????Receive(buffsizeof(buff)); //收到服務器發來的消息
????this->AsyncSelect(FD_CLOSE|FD_READ|FD_WRITE);
????Header?*header?=?(Header*)buff;
????int?length?=?header->len;
????char?type?=?header->type; //解析消息頭部
????if(type?==?SEND_MESSAGE) //如果是聊天內容,則直接接收
????{
????????chatDlg->GetMsgFromRoom();
????}
????if(type?==?LOGIN_IO) //在線用戶有變化,同步更新用戶表
????{
????????chatDlg->UpdateUser();
????}
????CSocket::OnReceive(nErrorCode);
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2017-10-26?13:19??1018聊天室網絡編程\
?????目錄???????????0??2017-12-19?11:33??1018聊天室網絡編程\SelfChat\
?????目錄???????????0??2017-10-18?20:19??1018聊天室網絡編程\SelfChat\Debug\
?????文件?????4992000??2017-10-18?20:19??1018聊天室網絡編程\SelfChat\Debug\SelfChat.pdb
?????目錄???????????0??2017-10-18?19:36??1018聊天室網絡編程\SelfChat\SelfChat\
?????文件???????????1??2009-08-31?02:32??1018聊天室網絡編程\SelfChat\SelfChat\ClassDiagram1.cd
?????文件?????????952??2017-12-19?11:33??1018聊天室網絡編程\SelfChat\SelfChat\ClientSocket.cpp
?????文件?????????355??2017-12-19?11:32??1018聊天室網絡編程\SelfChat\SelfChat\ClientSocket.h
?????目錄???????????0??2017-12-19?11:32??1018聊天室網絡編程\SelfChat\SelfChat\Debug\
?????文件??????104748??2017-12-19?11:33??1018聊天室網絡編程\SelfChat\SelfChat\Debug\CL.read.1.tlog
?????文件????????5354??2017-12-19?11:33??1018聊天室網絡編程\SelfChat\SelfChat\Debug\CL.write.1.tlog
?????文件?????????915??2017-10-18?19:38??1018聊天室網絡編程\SelfChat\SelfChat\Debug\SelfChat.exe.em
?????文件?????????980??2017-10-18?19:38??1018聊天室網絡編程\SelfChat\SelfChat\Debug\SelfChat.exe.em
?????文件?????????640??2017-10-18?20:19??1018聊天室網絡編程\SelfChat\SelfChat\Debug\SelfChat.exe.intermediate.manifest
?????文件?????????106??2017-12-19?11:33??1018聊天室網絡編程\SelfChat\SelfChat\Debug\SelfChat.lastbuildstate
?????文件????????5436??2017-12-19?11:33??1018聊天室網絡編程\SelfChat\SelfChat\Debug\SelfChat.log
?????文件???????34766??2017-12-19?11:32??1018聊天室網絡編程\SelfChat\SelfChat\Debug\SelfChat.obj
?????文件????33685504??2017-11-15?19:38??1018聊天室網絡編程\SelfChat\SelfChat\Debug\SelfChat.pch
?????文件???????70204??2017-10-18?19:38??1018聊天室網絡編程\SelfChat\SelfChat\Debug\SelfChat.res
?????文件???????????0??2017-12-19?11:33??1018聊天室網絡編程\SelfChat\SelfChat\Debug\SelfChat.unsuccessfulbuild
?????文件?????????713??2017-10-18?19:36??1018聊天室網絡編程\SelfChat\SelfChat\Debug\SelfChat.vcxprojResolveAssemblyReference.cache
?????文件???????????0??2017-10-18?19:36??1018聊天室網絡編程\SelfChat\SelfChat\Debug\SelfChat.write.1.tlog
?????文件?????????206??2017-10-18?19:38??1018聊天室網絡編程\SelfChat\SelfChat\Debug\SelfChat_manifest.rc
?????文件????????6858??2017-12-19?11:33??1018聊天室網絡編程\SelfChat\SelfChat\Debug\cl.command.1.tlog
?????文件???????????2??2017-10-18?20:19??1018聊天室網絡編程\SelfChat\SelfChat\Debug\li
?????文件???????????2??2017-10-18?20:19??1018聊天室網絡編程\SelfChat\SelfChat\Debug\li
?????文件???????????2??2017-10-18?20:19??1018聊天室網絡編程\SelfChat\SelfChat\Debug\li
?????文件???????????2??2017-10-18?20:19??1018聊天室網絡編程\SelfChat\SelfChat\Debug\li
?????文件???????????2??2017-10-18?20:19??1018聊天室網絡編程\SelfChat\SelfChat\Debug\li
?????文件?????????630??2017-10-18?19:38??1018聊天室網絡編程\SelfChat\SelfChat\Debug\mt.command.1.tlog
?????文件?????????604??2017-10-18?19:38??1018聊天室網絡編程\SelfChat\SelfChat\Debug\mt.read.1.tlog
............此處省略96個文件信息
- 上一篇:基于51單片機的智能安防報警系統
- 下一篇:MODIS NDVI
評論
共有 條評論