Visual C++通信编程实例
源代码在线查看: d113.bmp.txt
l
else
{
msg->Senalize(*m_aS essionOut);
m_aSessionOut->Flush0;
retum TRUE;
//对方关闭了连接
m_bClose=true;
CloseSocket0;
m_dlg->CloseSessionSocket0;
return FALSE;
7)添加CChatClient类关闭连接函数CloseSocket0。
void CChatClient::CloseSocket()
{
if(m_aSessionln)
{
delete m_aSessionln;
m_aSessionIn=NULL;
}
if(m_aSessionOut)
{
delete m_aSessionOut;
m_aSessionOut=NULL;
if(m_sfSocketFile)
{ .
delete m_aSessionOut;
m_sfSocketFile=NULL;
}
Close();
m_blnit=false;
m_bClose=true;
}
8)添加 CChatClient类获取主机名函数 GetLocalHostName O。
int CChatClient::GetLocaIHostName(CString &sHostName)
{
char szHostNamel256J;
int nRetCode;
nRetCode=gethostname(szHostN ame,sizeof(szHostName》;
if(nRetCode !:=:0)
{
//3