GithubHelp home page GithubHelp logo

Comments (3)

jiangguilong2000 avatar jiangguilong2000 commented on June 12, 2024

from kcp.

skywind3000 avatar skywind3000 commented on June 12, 2024

自己再 issue 里翻翻,别人传输速度比你这个快。

from kcp.

haozia816 avatar haozia816 commented on June 12, 2024

自己再 issue 里翻翻,别人传输速度比你这个快。

麻烦大神指导下呢,没有找到相似的issue,我是asio实现的,下面是伪代码

boost::asio::stready_timer	m_timer;

void active_update()
{
	ikcp_update(m_kcp);
	m_timer.expires_at(ikcp_check(m_kcp));
	m_timer.async_wait([]
	{
		active_update();
	});
}

//实例启动
void start()
{
	//开启周期性update
	active_update();
}

//网络接收到数据
void handle_recv(const uint8_t* data, size_t size)
{
	ikcp_input(m_kcp, data, size);
	while (true)
	{
		int len = ikcp_recv(m_kcp, buffer1);
		if(len == -1)
		{
			break; //无可用数据,结束while循环
		}
		//处理KCP接收到的数据,存储在buffer1中
		......
	}
	while (ikcp_waitsnd(m_kcp) < m_kcp->snd_wnd * 2)
	{
		//发送队列未满,继续读取文件发送
		if (pf) //FILE* pf;
		{
			fread(buffer2, 1, m_kcp->mss, pf);
			ikcp_send(m_kcp, buffer2, m_kcp->mss);
			active_update(); //测试过这里只能执行ikcp_update,执行ikcp_flush的话,数据不会立刻发送
		}
		else
		{
			break;
		}
	}
}

from kcp.

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.