本文整理汇总了C++中ACE_MEM_Stream::recv方法的典型用法代码示例。如果您正苦于以下问题:C++ ACE_MEM_Stream::recv方法的具体用法?C++ ACE_MEM_Stream::recv怎么用?C++ ACE_MEM_Stream::recv使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ACE_MEM_Stream
的用法示例。
在下文中一共展示了ACE_MEM_Stream::recv方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: to_server
int
run_client (u_short port,
ACE_MEM_IO::Signal_Strategy strategy)
{
int status = 0;
ACE_MEM_Addr to_server (port);
ACE_MEM_Connector connector;
connector.preferred_strategy (strategy);
ACE_MEM_Stream stream;
// connector.preferred_strategy (ACE_MEM_IO::MT);
if (connector.connect (stream, to_server.get_remote_addr ()) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("Failed to connect to <%C> %p\n"),
to_server.get_host_name (),
ACE_TEXT ("connector.connect()")),
-1);
ACE_TCHAR buf[MAXPATHLEN];
for (size_t cntr = 0; cntr < NUMBER_OF_ITERATIONS; cntr ++)
{
ACE_OS::snprintf (buf, MAXPATHLEN,
ACE_TEXT ("Iteration ") ACE_SIZE_T_FORMAT_SPECIFIER,
cntr);
ssize_t slen = (ACE_OS::strlen (buf) + 1) * sizeof (ACE_TCHAR);
if (stream.send (buf, slen) < slen)
{
ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"),
ACE_TEXT ("In stream.send()")));
status = -1;
break;
}
if (stream.recv (buf, MAXPATHLEN) == -1)
{
ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"),
ACE_TEXT ("stream.recv()")));
status = -1;
break;
}
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("run_client(), got echo %s\n"),
buf));
}
status = stream.close () == -1 ? -1 : status;
return status;
}
示例2: server_addr
static int
run_client (void)
{
ACE_MEM_Connector connector;
ACE_MEM_Stream stream;
ACE_MEM_Addr server_addr (ACE_DEFAULT_SERVER_PORT);
if (connector.connect (stream, server_addr.get_remote_addr ()) == -1)
ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "connect"), -1);
char buf [MAXPATHLEN];
while (fgets (buf, MAXPATHLEN, stdin) >0)
{
stream.send (buf, ACE_OS::strlen (buf)+1);
stream.recv (buf, MAXPATHLEN);
ACE_DEBUG ((LM_DEBUG, "Echo: %s\n", buf));
}
return 0;
}