I have the same question, and I found the reason recv always throws ConnNoError. Here is what I found. When the connection is established, recv calls funciton named dataAvailable In ConnectionTCPBase.cpp, which return
( ( select( m_socket + 1, &fds, 0, 0, timeout == -1 ? 0 : &tv ) > 0 ) && FD_ISSET( m_socket, &fds ) != 0 )
search google, , , FD_ISSET (m_socket, & fds) , readble, ... FD_ISSET (m_socket, & fds) 0, . dataAvailable , , , ConnNoError recv.
if( !dataAvailable( timeout ) )
{
m_recvMutex.unlock();
return ConnNoError;
}
, , , .
, , SIGPIPE, , , .
- , heartbeat.
gloox, heartBeat(), m_pClient gloox:: Client
void CXmpp::heartBeat()
{
m_pClient->xmppPing(m_pClient->jid(), this);
if (++heart) > 3) {
m_pClient->disconnect();
}
}
xmppPing eventhandler, ping , handleEvent handleEvent
void CEventHandler::handleEvent(const Event& event)
{
std::string sEvent;
switch (event.eventType())
{
case Event::PingPing:
sEvent = "PingPing";
break;
case Event::PingPong:
sEvent = "PingPong";
--heart;
break;
case Event::PingError:
sEvent = "PingError";
break;
default:
break;
}
return;
}
, , 3 !