本文整理汇总了C++中ACE_SPIPE_Addr::group_id方法的典型用法代码示例。如果您正苦于以下问题:C++ ACE_SPIPE_Addr::group_id方法的具体用法?C++ ACE_SPIPE_Addr::group_id怎么用?C++ ACE_SPIPE_Addr::group_id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ACE_SPIPE_Addr
的用法示例。
在下文中一共展示了ACE_SPIPE_Addr::group_id方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addr
int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
ACE_SPIPE_Acceptor peer_acceptor;
ACE_SPIPE_Stream new_stream;
struct pollfd poll_array[MAX_HANDLES];
ACE_HANDLE handle;
for (handle = 0; handle < MAX_HANDLES; handle++)
{
poll_array[handle].fd = -1;
poll_array[handle].events = POLLIN;
}
if (argc > 1)
rendezvous = argv[1];
ACE_OS::fdetach (ACE_TEXT_ALWAYS_CHAR (rendezvous));
ACE_SPIPE_Addr addr (rendezvous);
ACE_HANDLE s_handle = peer_acceptor.open (addr);
if (s_handle == -1)
ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "peer_acceptor.open"), -1);
poll_array[0].fd = s_handle;
for (int width = 1;;)
{
// Block waiting for client I/O events (handle interrupts).
while (ACE_OS::poll (poll_array, width) == -1 && errno == EINTR)
continue;
// Handle pending logging messages first (s_handle + 1 is
// guaranteed to be lowest client descriptor).
for (handle = s_handle + 1; handle < width; handle++)
if (ACE_BIT_ENABLED (poll_array[handle].revents, POLLIN)
|| ACE_BIT_ENABLED (poll_array[handle].revents, POLLHUP))
{
char buf[BUFSIZ];
ssize_t n = ACE_OS::read (handle, buf, sizeof buf);
// recv will not block in this case!
if (n == -1)
ACE_DEBUG ((LM_DEBUG, "%p\n", "read failed"));
else if (n == 0)
{
// Handle client connection shutdown.
if (ACE_OS::close (poll_array[handle].fd) == -1)
ACE_DEBUG ((LM_DEBUG, "%p\n", "close"));
poll_array[handle].fd = -1;
if (handle + 1 == width)
{
while (poll_array[handle].fd == -1)
handle--;
width = handle + 1;
}
}
else
ACE_DEBUG ((LM_DEBUG, "%*s\n", n, buf));
}
if (ACE_BIT_ENABLED (poll_array[0].revents, POLLIN))
{
if (peer_acceptor.accept (new_stream) == -1)
ACE_DEBUG ((LM_DEBUG, "%p\n", "accept failed"));
ACE_SPIPE_Addr client;
ACE_HANDLE n_handle = new_stream.get_handle ();
if (new_stream.get_remote_addr (client) == -1)
ACE_DEBUG ((LM_DEBUG, "%p\n",
"get_remote_addr failed"));
ACE_DEBUG ((LM_DEBUG,
"n_handle = %d, uid = %d, gid = %d\n",
n_handle,
client.user_id (),
client.group_id ()));
int arg = RMSGN | RPROTDAT;
if (ACE_OS::ioctl (n_handle,
I_SRDOPT, (void *) arg) == -1)
ACE_DEBUG ((LM_DEBUG, "%p\n", "ioctl failed"));
poll_array[n_handle].fd = n_handle;
if (n_handle >= width)
width = n_handle + 1;
}
}
ACE_NOTREACHED (return 0;)
}