本文整理汇总了C++中ACE_TLI_Stream::send方法的典型用法代码示例。如果您正苦于以下问题:C++ ACE_TLI_Stream::send方法的具体用法?C++ ACE_TLI_Stream::send怎么用?C++ ACE_TLI_Stream::send使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ACE_TLI_Stream
的用法示例。
在下文中一共展示了ACE_TLI_Stream::send方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void *
lookup_name (ACE_HANDLE handle)
{
enum
{
MAXLINE = 255,
EMPNAMELEN = 512
};
static struct
{
int emp_id;
const char *emp_name;
} employee_db[] =
{
{123, "John Wayne Bobbit"},
{124, "Woody Allen"},
{125, "O. J. Simpson"},
{126, "Bill Clinton"},
{127, "Rush Limbaugh"},
{128, "Michael Jackson"},
{129, "Kenneth Starr"},
{130, "Paula Jones"},
{131, "Monica Lewinsky"},
{132, "Marv Albert"},
{0, ""}
};
int flags;
int employee_id;
int index;
int found;
ACE_TLI_Stream stream;
char recvline[MAXLINE];
char sendline[MAXLINE];
ACE_DEBUG ((LM_DEBUG,
"stream handle = %d, thread id = %t\n",
handle));
stream.set_handle (handle);
ssize_t n = stream.recv (recvline, MAXLINE, &flags);
if (n == -1)
ACE_OS::t_error ("stream.recv error");
employee_id = ACE_OS::atoi (recvline);
found = 0;
for (index = 0; found == 0 && employee_db[index].emp_id; index++)
if (employee_id == employee_db[index].emp_id)
{
found = 1;
n = ACE_OS::sprintf (sendline,
"%s", employee_db[index].emp_name);
}
if (found == 0)
n = ACE_OS::sprintf (sendline, "%s", "ERROR");
if (stream.send (sendline, n + 1, 0) == -1)
ACE_OS::t_error ("stream.send error");
if (stream.sndrel () == -1)
ACE_OS::t_error ("stream.send error");
if (stream.close () == -1)
ACE_OS::t_error ("stream.close error");
return 0;
}