本文整理汇总了C++中Port::SayServer方法的典型用法代码示例。如果您正苦于以下问题:C++ Port::SayServer方法的具体用法?C++ Port::SayServer怎么用?C++ Port::SayServer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Port
的用法示例。
在下文中一共展示了Port::SayServer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Connect
int YARPPort::Connect(const char *src_name, const char *dest_name)
{
if (ACE_OS::strcmp (src_name, dest_name) == 0)
{
ACE_DEBUG ((LM_ERROR, "Silly you, you tried it, didn't you?\n"));
return YARP_FAIL;
}
// checking syntax.
if (src_name[0] != '*' && src_name[0] != '/')
{
ACE_DEBUG ((LM_ERROR, "The syntax of port connect is wrong\n"));
ACE_DEBUG ((LM_ERROR, "Please remember that valid names must start with\n"));
ACE_DEBUG ((LM_ERROR, "/ [forward slash]\n"));
ACE_DEBUG ((LM_ERROR, "The special symbol '*' is allowed when requesting\n"));
ACE_DEBUG ((LM_ERROR, "the active port connections\n"));
return YARP_FAIL;
}
// request port connections.
if (src_name[0] == '*')
{
YARPUniqueNameID* id = YARPNameService::LocateName (src_name+1, NULL);
if (id->getServiceType() != YARP_QNET) id->setServiceType (YARP_TCP);
id->setRequireAck(1);
YARPEndpointManager::CreateOutputEndpoint (*id);
int ret = YARPEndpointManager::ConnectEndpoints (*id, "explicit_connect");
if (ret == YARP_OK)
{
if (id->isValid())
{
Port p;
p.SayServer (id->getNameID(), src_name);
}
YARPEndpointManager::Close (*id);
YARPNameService::DeleteName (id);
return YARP_OK;
}
YARPEndpointManager::Close (*id);
YARPNameService::DeleteName (id);
return YARP_FAIL;
}
// assuming a valid name starting with /
if (src_name[0] == '/')
{
// NULL 2nd param means no net specified, only IP addr.
YARPUniqueNameID* id = YARPNameService::LocateName (src_name, NULL);
if (id->getServiceType() != YARP_QNET) id->setServiceType (YARP_TCP);
id->setRequireAck(1);
YARPEndpointManager::CreateOutputEndpoint (*id);
int ret = YARPEndpointManager::ConnectEndpoints (*id, "explicit_connect");
if (ret == YARP_OK)
{
if (id->isValid())
{
Port p;
p.SayServer (id->getNameID(), dest_name);
}
YARPEndpointManager::Close (*id);
YARPNameService::DeleteName (id);
return YARP_OK;
}
YARPEndpointManager::Close (*id);
YARPNameService::DeleteName (id);
// continues to next 'if'.
}
// can't connect, try a different strategy.
if (dest_name[0] == '!')
{
ACE_DEBUG ((LM_INFO, "trying again with direct connection\n"));
// tries again...
YARPUniqueNameID* id = YARPNameService::LocateName (dest_name+1, NULL);
if (id->getServiceType() != YARP_QNET) id->setServiceType (YARP_TCP);
id->setRequireAck(1);
YARPEndpointManager::CreateOutputEndpoint (*id);
int ret = YARPEndpointManager::ConnectEndpoints (*id, "explicit_connect");
if (ret == YARP_OK)
{
if (id->isValid())
{
Port p;
const int len = ACE_OS::strlen(src_name);
char *tmp_name = new char[len+2];
ACE_ASSERT (tmp_name != NULL);
//.........这里部分代码省略.........