本文整理汇总了C++中ACE_SPIPE_Addr类的典型用法代码示例。如果您正苦于以下问题:C++ ACE_SPIPE_Addr类的具体用法?C++ ACE_SPIPE_Addr怎么用?C++ ACE_SPIPE_Addr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ACE_SPIPE_Addr类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
int
ACE_SPIPE_Addr::set (const ACE_SPIPE_Addr &sa)
{
this->base_set (sa.get_type (), sa.get_size ());
if (sa.get_type () == AF_ANY)
(void) ACE_OS::memset ((void *) &this->SPIPE_addr_,
0,
sizeof this->SPIPE_addr_);
else
(void) ACE_OS::memcpy ((void *) &this->SPIPE_addr_, (void *)
&sa.SPIPE_addr_,
sa.get_size ());
return 0;
}
示例2: defined
int
ACE_SPIPE_Connector::connect (ACE_SPIPE_Stream &new_io,
const ACE_SPIPE_Addr &remote_sap,
ACE_Time_Value *timeout,
const ACE_Addr & /* local_sap */,
int /* reuse_addr */,
int flags,
int perms)
{
ACE_TRACE ("ACE_SPIPE_Connector::connect");
// Make darn sure that the O_CREAT flag is not set!
#if ! defined (ACE_PSOS_DIAB_MIPS)
ACE_CLR_BITS (flags, O_CREAT);
# endif /* !ACE_PSOS_DIAB_MIPS */
ACE_HANDLE handle = ACE_Handle_Ops::handle_timed_open (timeout,
remote_sap.get_path_name (),
flags, perms);
new_io.set_handle (handle);
new_io.remote_addr_ = remote_sap; // class copy.
#if defined (ACE_WIN32) && !defined (ACE_HAS_PHARLAP)
DWORD pipe_mode = PIPE_READMODE_MESSAGE | PIPE_WAIT;
// Set named pipe mode and buffering characteristics.
if (handle != ACE_INVALID_HANDLE)
return ::SetNamedPipeHandleState (handle,
&pipe_mode,
NULL,
NULL);
#endif
return handle == ACE_INVALID_HANDLE ? -1 : 0;
}
示例3:
ACE_SPIPE_Connector::ACE_SPIPE_Connector (ACE_SPIPE_Stream &new_io,
const ACE_SPIPE_Addr &remote_sap,
ACE_Time_Value *timeout,
const ACE_Addr & local_sap,
int reuse_addr,
int flags,
int perms)
{
ACE_TRACE ("ACE_SPIPE_Connector::ACE_SPIPE_Connector");
if (this->connect (new_io, remote_sap, timeout, local_sap,
reuse_addr, flags, perms) == -1
&& timeout != 0 && !(errno == EWOULDBLOCK || errno == ETIME))
ACE_ERROR ((LM_ERROR, ACE_LIB_TEXT ("address %s, %p\n"),
remote_sap.get_path_name (), ACE_LIB_TEXT ("ACE_SPIPE_Connector")));
}
示例4: relative_time
int
ACE_SPIPE_Connector::connect (ACE_SPIPE_Stream &new_io,
const ACE_SPIPE_Addr &remote_sap,
ACE_Time_Value *timeout,
const ACE_Addr & /* local_sap */,
int /* reuse_addr */,
int flags,
int perms,
LPSECURITY_ATTRIBUTES sa,
int pipe_mode)
{
ACE_TRACE ("ACE_SPIPE_Connector::connect");
// Make darn sure that the O_CREAT flag is not set!
ACE_CLR_BITS (flags, O_CREAT);
ACE_HANDLE handle;
ACE_UNUSED_ARG (pipe_mode);
#if defined (ACE_WIN32) && \
!defined (ACE_HAS_PHARLAP) && !defined (ACE_HAS_WINCE)
// We need to allow for more than one attempt to connect,
// calculate the absolute time at which we give up.
ACE_Time_Value absolute_time;
if (timeout != 0)
absolute_time = ACE_OS::gettimeofday () + *timeout;
// Loop until success or failure.
for (;;)
{
handle = ACE_OS::open (remote_sap.get_path_name(), flags, perms, sa);
if (handle != ACE_INVALID_HANDLE)
// Success!
break;
// Check if we have a busy pipe condition.
if (::GetLastError() != ERROR_PIPE_BUSY)
// Nope, this is a failure condition.
break;
// This will hold the time out value used in the ::WaitNamedPipe
// call.
DWORD time_out_value;
// Check if we are to block until we connect.
if (timeout == 0)
// Wait for as long as it takes.
time_out_value = NMPWAIT_WAIT_FOREVER;
else
{
// Calculate the amount of time left to wait.
ACE_Time_Value relative_time (absolute_time - ACE_OS::gettimeofday ());
// Check if we have run out of time.
if (relative_time <= ACE_Time_Value::zero)
{
// Mimick the errno value returned by
// ACE::handle_timed_open.
if (*timeout == ACE_Time_Value::zero)
errno = EWOULDBLOCK;
else
errno = ETIMEDOUT;
// Exit the connect loop with the failure.
break;
}
// Get the amount of time remaining for ::WaitNamedPipe.
time_out_value = relative_time.msec ();
}
// Wait for the named pipe to become available.
ACE_TEXT_WaitNamedPipe (remote_sap.get_path_name (),
time_out_value);
// Regardless of the return value, we'll do one more attempt to
// connect to see if it is now available and to return
// consistent error values.
}
// Set named pipe mode if we have a valid handle.
if (handle != ACE_INVALID_HANDLE)
{
// Check if we are changing the pipe mode from the default.
if (pipe_mode != (PIPE_READMODE_BYTE | PIPE_WAIT))
{
DWORD dword_pipe_mode = pipe_mode;
if (!::SetNamedPipeHandleState (handle,
&dword_pipe_mode,
0,
0))
{
// We were not able to put the pipe into the requested
// mode.
ACE_OS::close (handle);
handle = ACE_INVALID_HANDLE;
}
}
}
#else /* ACE_WIN32 && !ACE_HAS_PHARLAP */
handle = ACE::handle_timed_open (timeout,
remote_sap.get_path_name (),
flags, perms, sa);
//.........这里部分代码省略.........
示例5: ACE_TMAIN
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;)
}