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