本文整理汇总了C++中Tcp::isConnected方法的典型用法代码示例。如果您正苦于以下问题:C++ Tcp::isConnected方法的具体用法?C++ Tcp::isConnected怎么用?C++ Tcp::isConnected使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tcp
的用法示例。
在下文中一共展示了Tcp::isConnected方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: findFreeTcp
Tcp* Tcp::findFreeTcp(struct espconn* pconn) {
Tcp* cursor;
for (cursor = _first; cursor != 0; cursor = cursor->_next)
if ((cursor->isConnected() == false) && (cursor->getType() == LIVE))
return cursor;
return 0;
}
示例2: dispatch
bool dispatch(Msg& msg)
{
PT_BEGIN ( );
while(true)
{
PT_YIELD_UNTIL( msg.is(_tcp,SIG_RXD) || msg.is(_usb,SIG_RXD) );
if ( msg.is(_tcp,SIG_RXD))
{
MqttIn* mqttIn = (MqttIn*)msg.data;
Str str(256);
str << "MQTT TCP->USB:";
mqttIn->toString(str);
logger.info()<< str;
logger.flush();
usb.send(*mqttIn->getBytes());
}
else if ( msg.is(_usb,SIG_RXD))
{
MqttIn* mqttIn = (MqttIn*)msg.data;
Str str(256);
str << "MQTT USB->TCP:";
mqttIn->toString(str);
logger.info()<< str;
logger.flush();
if ( _tcp->isConnected() )
{
if ( mqttIn->type() == MQTT_MSG_CONNECT ) // simulate a reply
{
MqttOut m(10);
m.ConnAck(0);
// uint8_t CONNACK[]={0x20,0x02,0x00,0x00};
logger.info()<< "CONNACK virtual,already tcp connected";
logger.flush();
usb.send(m);
}
else
{
tcp.send(*mqttIn->getBytes());
}
}
else
{
if ( mqttIn->type() == MQTT_MSG_CONNECT )
{
tcp.connect();
tcp.send(*mqttIn->getBytes());
}
else
{
logger.info()<< "dropped packet, not connected.";
logger.flush();
usb.disconnect();
}
}
}
}
PT_END ( );
}
示例3: listTcp
void Tcp::listTcp() {
Tcp* cursor;
char line[120];
line[0] = 0;
for (cursor = _first; cursor != 0; cursor = cursor->_next) {
os_sprintf(line + strlen(line), "/ %X:%X %d %d", (uint32_t) cursor,
cursor->_conn, cursor->getType(), cursor->isConnected());
}
LOGF(line);
}