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

📄 mysocket.cpp

📁 实现文件传书是很有用的一个传书软件是大势的比口欧式
💻 CPP
字号:
// MySocket.cpp : implementation file
//

#include "stdafx.h"
#include "FileTransferServer.h"
#include "MySocket.h"

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

/////////////////////////////////////////////////////////////////////////////
// CMySocket

CMySocket::CMySocket():Thdidx(0)
{
}

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
//OnAccept函数重载
void CMySocket::OnAccept(int nErrorCode)
{
	static int Accepted=0;
	if(!listenSocket.Accept(sendSockets[Accepted]))
	{
		AfxMessageBox("Connect Fail");
		return;
	}
	sendSockets[Accepted].AsyncSelect(FD_ACCEPT|FD_WRITE|FD_CLOSE);
	Thdidx=++Accepted;
	if(Accepted==NumOfThread)
	{
		AfxMessageBox("Connect Success");
		listenSocket.Close();
	}
	CAsyncSocket::OnAccept(nErrorCode);
}
//OnSend重载函数
void CMySocket::OnSend(int nErrorCode)
{
	//设置文件发送事件对象,通知线程可以发送数据
	SetEvent(hMessageSend[Thdidx-1]);
	CAsyncSocket::OnSend(nErrorCode);
}

⌨️ 快捷键说明

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