本文整理汇总了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;
}
示例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;
}