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

📄 clientsocketlist.cpp

📁 mfc编写的聊天室程序,支持多用户间 收发消息 。
💻 CPP
字号:
// ClientSocketList.cpp: implementation of the CClientSocketList class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "Server.h"
#include "ClientSocketList.h"

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

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CClientSocketList::CClientSocketList()
{
	Head=0;
}

CClientSocketList::~CClientSocketList()
{

}

BOOL CClientSocketList::Add(CClientSocket *add)
{
	CClientSocket *tmp=Head;
	SOCKADDR sockadd;
	int lens;
	lens = sizeof(SOCKADDR);
	add->GetPeerName(&sockadd,&lens);
		
	if (!Head)
	{
		Head=add;
		return true;
	}
	while (tmp->Next) tmp=tmp->Next;
	tmp->Next=add;
	return true;
}

BOOL CClientSocketList::Sends(CClientSocket *tmp)
{
	char buff[1000];
	int n;
	CClientSocket *curr=Head;
	n=tmp->Receive(buff,1000);
	buff[n]=0;
	while (curr)
	{

		curr->Send(buff,n);
		curr=curr->Next;

	}
	return true;
}

⌨️ 快捷键说明

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