当前位置: 首页>>代码示例>>C++>>正文


C++ Tcp::loadEspconn方法代码示例

本文整理汇总了C++中Tcp::loadEspconn方法的典型用法代码示例。如果您正苦于以下问题:C++ Tcp::loadEspconn方法的具体用法?C++ Tcp::loadEspconn怎么用?C++ Tcp::loadEspconn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tcp的用法示例。


在下文中一共展示了Tcp::loadEspconn方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: disconnectCb

void Tcp::disconnectCb(void* arg) {
	struct espconn* pconn = (struct espconn*) arg;

	Tcp *pTcp = findTcp(pconn);
	if (pTcp) {
		pTcp->_connected = false;
		if (pTcp->getType() == LIVE) {
			pTcp->loadEspconn(0);
		}
		pTcp->self().tell(pTcp->self(), REPLY(DISCONNECT), 0);
	} else
		LOGF("connection not found");
	return;
}
开发者ID:vortex314,项目名称:ea_actor,代码行数:14,代码来源:Tcp.cpp

示例2: connectCb

void Tcp::connectCb(void* arg) {
//	LOGF(" tcp connection received");

	struct espconn* pconn = (struct espconn*) arg;

	Tcp* pTcp = findTcp(pconn); // if found it's TcpClient

	if (pTcp == 0) {
		pTcp = findFreeTcp(pconn);
	}

	if (pTcp) {

		pTcp->loadEspconn(pconn);
		pTcp->registerCb(pconn);
		pTcp->_state = READY;

		/*		uint32_t keeplive;

		 espconn_set_opt(pesp_conn, ESPCONN_KEEPALIVE); // enable TCP keep alive

		 //set keepalive: 75s = 60 + 5*3
		 keeplive = 60;
		 espconn_set_keepalive(pesp_conn, ESPCONN_KEEPIDLE, &keeplive);
		 keeplive = 5;
		 espconn_set_keepalive(pesp_conn, ESPCONN_KEEPINTVL, &keeplive);
		 keeplive = 3; //try times
		 espconn_set_keepalive(pesp_conn, ESPCONN_KEEPCNT, &keeplive);  */
//		espconn_set_opt(pconn, ESPCONN_NODELAY);
//		espconn_set_opt(pconn, ESPCONN_COPY);
//		espconn_set_keepalive(pconn, ESPCONN_KEEPALIVE, (void*) 1);
//		espconn_set_keepalive(pconn, ESPCONN_KEEPIDLE, (void*) 1);
//		espconn_regist_time(pconn, 100, 0);
		pTcp->listener().tell(pTcp->self(), REPLY(CONNECT), 0);
		pTcp->_buffer.clear();
		pTcp->_txd.clear();
		pTcp->_connected = true;
		pTcp->_lastRxd = Sys::millis();
		pTcp->_state = READY;
	} else {
		LOGF(" no free TCP : disconnecting %X ", pconn);
		LOGF("  tcp :  %x  , ip : %d.%d.%d.%d:%d  ",
				pconn->reverse, pconn->proto.tcp->remote_ip[0], pconn->proto.tcp->remote_ip[1], pconn->proto.tcp->remote_ip[2], pconn->proto.tcp->remote_ip[3], pconn->proto.tcp->remote_port);
		espconn_disconnect(pconn);
	}
	return;
}
开发者ID:vortex314,项目名称:ea_stm32,代码行数:47,代码来源:Tcp.cpp


注:本文中的Tcp::loadEspconn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。