本文整理汇总了C++中TcpConnection::onError方法的典型用法代码示例。如果您正苦于以下问题:C++ TcpConnection::onError方法的具体用法?C++ TcpConnection::onError怎么用?C++ TcpConnection::onError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TcpConnection
的用法示例。
在下文中一共展示了TcpConnection::onError方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: JTRACE
void
SocketConnList::drain()
{
// First, let all the Connection prepare for drain
ConnectionList::drain();
// this will block until draining is complete
KernelBufferDrainer::instance().monitorSockets(DRAINER_CHECK_FREQ);
// handle disconnected sockets
const map<ConnectionIdentifier, vector<char> > &discn =
KernelBufferDrainer::instance().getDisconnectedSockets();
map<ConnectionIdentifier, vector<char> >::const_iterator it;
for (it = discn.begin(); it != discn.end(); it++) {
const ConnectionIdentifier &id = it->first;
TcpConnection *con =
(TcpConnection *)SocketConnList::instance().getConnection(id);
JTRACE("recreating disconnected socket") (id);
// reading from the socket, and taking the error, resulted in an
// implicit close().
// we will create a new, broken socket that is not closed
con->onError();
}
}
示例2: 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;
}
示例3: staticOnError
void TcpConnection::staticOnError(void *arg, err_t err)
{
TcpConnection* con = (TcpConnection*)arg;
if (con == NULL) return;
con->tcp = NULL; // IMPORTANT. No available connection after error!
con->onError(err);
con->checkSelfFree();
//debugf("<staticOnError");
}