mysocket.cpp
来自「计算机是网络的一个课程设计。文件传输&聊天 里面是WORD类型(包含源代码)」· C++ 代码 · 共 60 行
CPP
60 行
// MySocket.cpp : implementation file
//
#include "stdafx.h"
#include "lancommunion.h"
#include "MySocket.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
////////////////////////////////////////////////////////////////////////////
CMySocket sendSockets[5];
CMySocket listenSocket;
/////////////////////////////////////////////////////////////////////////////
// CMySocket
CMySocket::CMySocket()
{
}
CMySocket::~CMySocket()
{
}
// Do not edit the following lines, which are needed by ClassWizard.
#if 0
BEGIN_MESSAGE_MAP(CMySocket, CAsyncSocket)
//{{AFX_MSG_MAP(CMySocket)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
#endif // 0
/////////////////////////////////////////////////////////////////////////////
// CMySocket member functions
void CMySocket::OnAccept(int nErrorCode)
{
// TODO: Add your specialized code here and/or call the base class
static int acceptNum=0;
int err;
if( !( err=listenSocket.Accept(sendSockets[acceptNum]) ) )
{
AfxMessageBox("接收连接失败。");
return ;
}
sendSockets[acceptNum].AsyncSelect(FD_READ|FD_WRITE|FD_CLOSE);
acceptNum++;
if(5==acceptNum)
{
AfxMessageBox("接收连接成功。");
listenSocket.Close( );
}
CAsyncSocket::OnAccept(nErrorCode);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?