本文整理汇总了C++中TcpConnection::onReceive方法的典型用法代码示例。如果您正苦于以下问题:C++ TcpConnection::onReceive方法的具体用法?C++ TcpConnection::onReceive怎么用?C++ TcpConnection::onReceive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TcpConnection
的用法示例。
在下文中一共展示了TcpConnection::onReceive方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: staticOnReceive
err_t TcpConnection::staticOnReceive(void *arg, tcp_pcb *tcp, pbuf *p, err_t err)
{
// debugf("Static OnReceive buf = %d", tcp_sndbuf(tcp));
TcpConnection* con = (TcpConnection*)arg;
err_t ret_err;
//Serial.println("echo_recv!");
if (con == NULL)
{
if (p != NULL)
{
/* Inform TCP that we have taken the data. */
tcp_recved(tcp, p->tot_len);
pbuf_free(p);
}
closeTcpConnection(tcp);
return ERR_OK;
}
else
con->sleep = 0;
if (err != ERR_OK /*&& err != ERR_CLSD && err != ERR_RST*/)
{
debugf("Received ERROR %d", err);
/* exit and free resources, for unkown reason */
if (p != NULL)
{
/* Inform TCP that we have taken the data. */
tcp_recved(tcp, p->tot_len);
pbuf_free(p);
}
closeTcpConnection(tcp); // ??
con->tcp = NULL;
con->onError(err);
//con->close();
return err == ERR_ABRT ? ERR_ABRT : ERR_OK;
}
//if (tcp != NULL && tcp->state == ESTABLISHED) // If active
/* We have taken the data. */
if (p != NULL)
tcp_recved(tcp, p->tot_len);
err_t res = con->onReceive(p);
if (p != NULL)
pbuf_free(p);
else
{
con->close();
closeTcpConnection(tcp);
}
con->checkSelfFree();
//debugf("<staticOnReceive");
return res;
}