www.pudn.com > Socket编程经典例子源码.rar > ListenSocket.cpp


// ListenSocket.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "Server.h" 
#include "ListenSocket.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CListenSocket 
 
CListenSocket::CListenSocket() 
{ 
	m_nSocketCount=0; 
	for(int i=0;i<10;i++) 
	{ 
		m_pServerSocket[i]=NULL; 
	} 
} 
 
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)  
{ 
	// TODO: Add your specialized code here and/or call the base class 
	CServerSocket* pSocket=new CServerSocket; 
 
	CSocket::Accept (*pSocket); 
 
	CSocket::OnAccept(nErrorCode); 
	 
	m_pServerSocket[m_nSocketCount] = pSocket; 
	pSocket->m_pParentWnd=m_pParentWnd; 
	m_nSocketCount++; 
//	m_pParentWnd->PostMessage(WM_UPDATECOUNT,(WPARAM)m_nSocketCount,0); 
} 
 
void CListenSocket::OnConnect(int nErrorCode)  
{ 
	// TODO: Add your specialized code here and/or call the base class 
	CSocket::OnConnect(nErrorCode); 
}