Coder Social home page Coder Social logo

Comments (2)

ldcsaa avatar ldcsaa commented on July 25, 2024

1、什么平台,什么组件?
2、完整demo代码
3、发不出去是程序卡住还是对方收不到,如果是后者检查一下send的getlasterror

from hp-socket.

Lioncky avatar Lioncky commented on July 25, 2024

1、什么平台,什么组件? 2、完整demo代码 3、发不出去是程序卡住还是对方收不到,如果是后者检查一下send的getlasterror

很抱歉到现在才回复 因为之前没有收到邮件

Win32, 版本是lateset
组件是CTcpServerPtr
这个问题目前还存在
getlasterror无有效信息

目前来说短暂延迟可以解决问题 也许是c++性能太强导致的???

BOOL CS_SendAllEx(ESTR& nData) {
	static CONNID scArg[0x10000];
	DWORD dwCount; BOOL bSafe; CONNID* sArg;

	dwCount = CServer->GetConnectionCount();
	if (dwCount == 0) {
		DDS(einfunc "当前无用户[%s]", nData);
		return TRUE;
	}

	bSafe = dwCount < _ARRAYSIZE(scArg); // Cookie Mode
	sArg = bSafe ? scArg : (CONNID*)malloc(sizeof CONNID * dwCount);
	if (sArg == nullptr) {
		DDF(einfunc "没有足够的空间[%s]", nData.data());
		return FALSE;
	}
	
	// 1.取出所有客户
	CServer->GetAllConnectionIDs(sArg, dwCount);

	while (dwCount--) {
		CServer->Send(sArg[dwCount], nData, nData.lenth());
		::Sleep(18); // 强制性延迟防止send太快而数据未发出 也许是BUG???
	}

	// 3. 释放申请的内存
	if (!bSafe) ::free(scArg);

	return TRUE;
}

from hp-socket.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.