⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mysock.cpp

📁 一个聊天的程序不错
💻 CPP
字号:
// mysock.cpp : implementation file
//



#include "stdafx.h"
#include "聊天程序.h"
#include "mysock.h"


#include "聊天程序Dlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// mysock

mysock::mysock()
{
}

mysock::~mysock()
{
	m_hSocket=INVALID_SOCKET;
	//delete pWorkSock;
}


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

/////////////////////////////////////////////////////////////////////////////
// mysock member functions

void mysock::OnAccept(int nErrorCode) 
{
	// TODO: Add your specialized code here and/or call the base class
	//侦听到连接请求,调用Accept函数	
	workingSock* pSocketNew = new workingSock();
	if (Accept(*pSocketNew))	
	{    
		//仅让系统给 ‘收发SOCKET’发送‘可接收消息’
		pSocketNew->AsyncSelect(FD_READ); 
		pWorkSock=pSocketNew;
		//AfxMessageBox("server connection OK",MB_OK);
		   //用于使‘send’变黑
		CWinApp* thisApp;        //获得进程的句柄
		thisApp=AfxGetApp();
	
        CMyDlg *dialWnd;      //获得对话框的句柄
	    dialWnd=(CMyDlg *)thisApp->GetMainWnd();
	    CWnd  *sendBut,*mesEdit;
        sendBut=dialWnd->GetDlgItem(IDC_BUTTON3);
		mesEdit=dialWnd->GetDlgItem(IDC_EDIT3);
        sendBut->EnableWindow(TRUE); 
		mesEdit->EnableWindow(TRUE);
		
	}	
	else    
	delete pSocketNew;
	CAsyncSocket::OnAccept(nErrorCode);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -