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


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

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


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

示例1: recvCb

void Tcp::recvCb(void* arg, char *pdata, unsigned short len) {

	struct espconn* pconn = (struct espconn*) arg;
	Tcp *pTcp = findTcp(pconn);
	if (pTcp) {
		pTcp->_bytesRxd += len;
		pTcp->_lastRxd = Sys::millis();
		Bytes bytes;
		bytes.map((uint8_t*) pdata, (uint32_t) len);
		Erc erc;
		pTcp->listener().tell(Header(pTcp->listener(), pTcp->self(), RXD, 0),
				_cborOut.putf("B", &bytes));
	} else {
		LOGF(" Tcp not found ");
	}
}
开发者ID:vortex314,项目名称:ea_stm32,代码行数:16,代码来源:Tcp.cpp

示例2: sendCb

void Tcp::sendCb(void *arg) {
	sends_cb++;
	struct espconn* pconn = (struct espconn*) arg;
	Tcp *pTcp = findTcp(pconn);
	if (pTcp) {
		pTcp->_state = READY;
		pTcp->send();
		pTcp->listener().tell(pTcp->self(), REPLY(TXD), 0);
	} else {
		LOGF("Tcp not found");
	}
	return;
}
开发者ID:vortex314,项目名称:ea_stm32,代码行数:13,代码来源:Tcp.cpp

示例3: reconnectCb

void Tcp::reconnectCb(void* arg, int8_t err) {
	struct espconn* pconn = (struct espconn*) arg;
	Tcp *pTcp = findTcp(pconn);
	if (pTcp) {
		pTcp->_state = READY;
		pTcp->_buffer.clear();
		pTcp->_txd.clear();

		LOGF("TCP: Reconnect %s:%d err : %d",
				pTcp->_host, pTcp->_remote_port, err);
		pTcp->listener().tell(pTcp->self(), REPLY(DISCONNECT), 0);
		pTcp->_connected = false;
	} else
		LOGF("connection not found");
}
开发者ID:vortex314,项目名称:ea_stm32,代码行数:15,代码来源:Tcp.cpp

示例4: disconnectCb

void Tcp::disconnectCb(void* arg) {
//	LOGF(" tcp disconnection received");
	struct espconn* pconn = (struct espconn*) arg;

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

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