本文整理汇总了C++中ConnectionPtr::recvNB方法的典型用法代码示例。如果您正苦于以下问题:C++ ConnectionPtr::recvNB方法的具体用法?C++ ConnectionPtr::recvNB怎么用?C++ ConnectionPtr::recvNB使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConnectionPtr
的用法示例。
在下文中一共展示了ConnectionPtr::recvNB方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _handleData
bool LocalNode::_handleData()
{
ConnectionPtr connection = _incoming.getConnection();
EQASSERT( connection.isValid( ));
NodePtr node;
ConnectionNodeHash::const_iterator i = _connectionNodes.find( connection );
if( i != _connectionNodes.end( ))
node = i->second;
EQASSERTINFO( !node || // unconnected node
*(node->_outgoing) == *connection || // correct UC connection
connection->getDescription()->type>=CONNECTIONTYPE_MULTICAST,
base::className( node ));
EQVERB << "Handle data from " << node << std::endl;
void* sizePtr( 0 );
uint64_t bytes( 0 );
const bool gotSize = connection->recvSync( &sizePtr, &bytes, false );
if( !gotSize ) // Some systems signal data on dead connections.
{
connection->recvNB( sizePtr, sizeof( uint64_t ));
return false;
}
EQASSERT( sizePtr );
const uint64_t size = *reinterpret_cast< uint64_t* >( sizePtr );
if( bytes == 0 ) // fluke signal
{
EQWARN << "Erronous network event on " << connection->getDescription()
<< std::endl;
_incoming.setDirty();
return false;
}
EQASSERT( size );
EQASSERTINFO( bytes == sizeof( uint64_t ), bytes );
EQASSERT( size > sizeof( size ));
if( node )
node->_lastReceive = getTime64();
Command& command = _commandCache.alloc( node, this, size );
uint8_t* ptr = reinterpret_cast< uint8_t* >(
command.getModifiable< Packet >()) + sizeof( uint64_t );
connection->recvNB( ptr, size - sizeof( uint64_t ));
const bool gotData = connection->recvSync( 0, 0 );
EQASSERT( gotData );
EQASSERT( command.isValid( ));
EQASSERT( command.isFree( ));
// start next receive
connection->recvNB( sizePtr, sizeof( uint64_t ));
if( !gotData )
{
EQERROR << "Incomplete packet read: " << command << std::endl;
return false;
}
// This is one of the initial packets during the connection handshake, at
// this point the remote node is not yet available.
EQASSERTINFO( node.isValid() ||
( command->type == PACKETTYPE_CO_NODE &&
( command->command == CMD_NODE_CONNECT ||
command->command == CMD_NODE_CONNECT_REPLY ||
command->command == CMD_NODE_ID )),
command << " connection " << connection );
_dispatchCommand( command );
return true;
}
示例2: _addConnection
void LocalNode::_addConnection( ConnectionPtr connection )
{
_incoming.addConnection( connection );
connection->recvNB( new uint64_t, sizeof( uint64_t ));
}