?? listensocket.cpp
字號(hào):
// ListenSocket.cpp : implementation file
//
#include "stdafx.h"
#include "SecretChat.h" //應(yīng)用程序類頭文件
#include "ListenSocket.h"
#include "ServiceSocket.h"
#include "SecretChatDlg.h" //主窗口類頭文件
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CListenSocket
CListenSocket::CListenSocket()
{
}
CListenSocket::~CListenSocket()
{
}
// Do not edit the following lines, which are needed by ClassWizard.
#if 0
BEGIN_MESSAGE_MAP(CListenSocket, CSocket)
//{{AFX_MSG_MAP(CListenSocket)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
#endif // 0
/////////////////////////////////////////////////////////////////////////////
// CListenSocket member functions
void CListenSocket::OnAccept(int nErrorCode)
{
CSecretChatDlg * pMain = (CSecretChatDlg *)AfxGetMainWnd();
if(pMain->m_online)
{
//已經(jīng)聯(lián)機(jī)就不在聯(lián)機(jī)了
pMain->m_statusMessages.SetWindowText("有人嘗試連接");
::MessageBeep(MB_OK);
return;
}
if( NULL != (m_pServiceSocket = new CServiceSocket)//構(gòu)造套接字
&& Accept(*m_pServiceSocket) )
{
pMain->m_clientOrService = TRUE; //服務(wù)器端
pMain->connect_succeed_update();
}
else
{
pMain->m_statusMessages.SetWindowText("連接失敗!");
//關(guān)閉套接字
pMain->CloseSocket();
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -