xxxx18一60岁hd中国/日韩女同互慰一区二区/西西人体扒开双腿无遮挡/日韩欧美黄色一级片 - 色护士精品影院www

資源簡介

采用的C++,MFC編寫的聊天室軟件,有語音聊天,文件傳輸,文字聊天功能。服務器和客戶端是封裝到一起的。界面是最簡潔經典的界面,沒有進行優化和美化。代碼可以直接運行。

資源截圖

代碼片段和文件信息

//?ChatClient.cpp?:?implementation?file
//

#include?“stdafx.h“
#include?“ChatRoom.h“
#include?“ChatClient.h“
#include?“ChatRoomDlg.h“

#ifdef?_DEBUG
#define?new?DEBUG_NEW
#undef?THIS_FILE
static?char?THIS_FILE[]?=?__FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
//?CChatClient

CChatClient::CChatClient()
{
m_aSessionIn=NULL;//串行化方式輸入數據
m_aSessionOut=NULL;//串行輸出數據
m_sfSocketFile=NULL;//和Socket關聯的串行化文件
m_bInit=false;
m_bClose=false;
}

CChatClient::~CChatClient()
{
if(m_aSessionIn)
delete?m_aSessionIn;
if(m_aSessionOut)
delete?m_aSessionOut;
if(m_sfSocketFile)
delete?m_sfSocketFile;
}


//?Do?not?edit?the?following?lines?which?are?needed?by?ClassWizard.
#if?0
BEGIN_MESSAGE_MAP(CChatClient?CSocket)
//{{AFX_MSG_MAP(CChatClient)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
#endif //?0

/////////////////////////////////////////////////////////////////////////////
//?CChatClient?member?functions



void?CChatClient::Init(CChatRoomDlg?*dlg)
{
m_sfSocketFile=new?CSocketFile(this);
m_aSessionIn=new?CArchive(m_sfSocketFileCArchive::load);
m_aSessionOut=new?CArchive(m_sfSocketFileCArchive::store);
m_bClose=false;
this->m_dlg=dlg;
}

BOOL?CChatClient::SendMessage(CMessg?*msg)
{
if(m_aSessionOut?!=?NULL)
{
msg->Serialize(*m_aSessionOut);
m_aSessionOut->Flush();
return?TRUE;
}
else
{//對方關閉了連接
m_bClose=true;
CloseSocket();
m_dlg->CloseSessionSocket();
return?FALSE;
}
}

void?CChatClient::CloseSocket()
{
if(m_aSessionIn)
{
delete?m_aSessionIn;
m_aSessionIn=NULL;
}
if(m_aSessionOut)
{
delete?m_aSessionOut;
m_aSessionOut=NULL;
}
if(m_sfSocketFile)
{
delete?m_aSessionOut;
m_sfSocketFile=NULL;
}
Close();
m_bInit=false;
m_bClose=true;
}


//獲得主機名
int?CChatClient::GetLocalHostName(CString?&sHostName)
{
char?szHostName[256];
int?nRetCode;
nRetCode=gethostname(szHostNamesizeof(szHostName));
if(nRetCode!=0)
{
sHostName=_T(“沒有取得“);
return?GetLastError();
}
sHostName=szHostName;
return?0;
}

//獲得本地IP地址
int?CChatClient::GetIpAddress(const?CString?&sHostNameCString?&sIpAddress)
{
struct?hostent?FAR?*?lpHostEnt=gethostbyname(sHostName);
if(lpHostEnt==NULL)
{
sIpAddress=_T(““);
return?GetLastError();
}
LPSTR?lpAddr=lpHostEnt->h_addr_list[0];/*?list?of?addresses?*/
if(lpAddr)
{
struct?in_addr?inAddr;
memmove(&inAddrlpAddr4); //(目的對象,源對象,字符復制的字節數)轉換為標準格式
sIpAddress=inet_ntoa(inAddr);//inet_ntoa函數將一個(Ipv4)互聯網絡地址轉換成一個字符串在互聯網標準點格式。
if(sIpAddress.IsEmpty())
sIpAddress=_T(“沒有取得IP地址“);
}
return?0;

}

//獲得本地IP地址
int?CChatClient::GetIpAddress(const?CString?&sHostNameBYTE?&f0BYTE?&f1BYTE?&f2BYTE?&f3)
{
struct?hostent?FAR?*?lpHostEnt=gethostbyname(sHostName);
if(lpHostEnt==NULL)
{
f0=f1=f2=f3=0;
return?GetLastError();
}
LPSTR?lpAddr=lpHostEnt->h_addr_list[0];
if(lpAddr)
{
struct?in

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2014-05-26?21:18??ChatRoom\
?????文件????????6309??2014-05-09?09:43??ChatRoom\ChatClient.cpp
?????文件????????1917??2014-05-09?20:31??ChatRoom\ChatClient.h
?????文件???????37500??2014-05-10?09:43??ChatRoom\ChatRoom.aps
?????文件????????3030??2014-05-26?21:18??ChatRoom\ChatRoom.clw
?????文件????????2185??2014-04-26?11:18??ChatRoom\ChatRoom.cpp
?????文件????????4892??2014-04-30?10:31??ChatRoom\ChatRoom.dsp
?????文件?????????541??2014-04-26?11:18??ChatRoom\ChatRoom.dsw
?????文件????????1346??2014-04-26?11:18??ChatRoom\ChatRoom.h
?????文件???????82944??2014-05-26?21:18??ChatRoom\ChatRoom.ncb
?????文件???????57856??2014-05-26?21:18??ChatRoom\ChatRoom.opt
?????文件?????????250??2014-05-26?18:50??ChatRoom\ChatRoom.plg
?????文件????????7700??2014-05-10?09:43??ChatRoom\ChatRoom.rc
?????文件???????11283??2014-05-11?14:49??ChatRoom\ChatRoomDlg.cpp
?????文件????????2586??2014-05-08?11:05??ChatRoom\ChatRoomDlg.h
?????文件????????1271??2014-04-28?11:15??ChatRoom\ChatServer.cpp
?????文件????????1274??2014-04-26?12:01??ChatRoom\ChatServer.h
?????文件????????1483??2014-04-29?14:13??ChatRoom\CMessg.cpp
?????文件?????????658??2014-04-29?14:13??ChatRoom\CMessg.h
?????目錄???????????0??2014-05-26?18:49??ChatRoom\Debug\
?????文件???????31528??2014-05-26?18:49??ChatRoom\Debug\ChatClient.obj
?????文件???????68605??2014-05-26?18:49??ChatRoom\Debug\ChatClient.sbr
?????文件?????4006912??2014-04-29?14:38??ChatRoom\Debug\ChatRoom.bsc
?????文件??????139331??2014-05-26?18:49??ChatRoom\Debug\ChatRoom.exe
?????文件??????451976??2014-05-26?18:49??ChatRoom\Debug\ChatRoom.ilk
?????文件???????17404??2014-05-26?18:49??ChatRoom\Debug\ChatRoom.obj
?????文件?????7087752??2014-04-29?10:55??ChatRoom\Debug\ChatRoom.pch
?????文件??????517120??2014-05-26?18:49??ChatRoom\Debug\ChatRoom.pdb
?????文件????????3812??2014-05-10?09:43??ChatRoom\Debug\ChatRoom.res
?????文件???????66557??2014-05-26?18:49??ChatRoom\Debug\ChatRoom.sbr
?????文件???????61451??2014-05-26?18:49??ChatRoom\Debug\ChatRoomDlg.obj
............此處省略27個文件信息

評論

共有 條評論