www.pudn.com > 6manager_server.rar > ListenSocket.cpp
// ListenSocket.cpp : implementation file
//
#include "stdafx.h"
#include "manager_server.h"
#include "ListenSocket.h"
#include "manager_serverDlg.h"
#include "ClientSocket.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)
{
// TODO: Add your specialized code here and/or call the base class
CClientSocket *pSocket=new CClientSocket();
CManager_serverDlg * pMainWnd=((CManager_serverDlg*)(AfxGetApp()->m_pMainWnd));
if(pMainWnd->m_pSocket->Accept(*pSocket))
{
pMainWnd->m_SocketList.AddTail(pSocket);
//pMainWnd->MessageBox("监听到一个连接","服务器地址");
}
else
delete pSocket;
CSocket::OnAccept(nErrorCode);
}