clientsocketlist.cpp

来自「模拟QQ的网络聊天程序」· C++ 代码 · 共 56 行

CPP
56
字号
// ClientSocketList.cpp: implementation of the CClientSocketList class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "ChatRoomServer.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;
	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 + =
减小字号Ctrl + -
显示快捷键?