本文整理汇总了C++中ACE_Handle_Set::is_set方法的典型用法代码示例。如果您正苦于以下问题:C++ ACE_Handle_Set::is_set方法的具体用法?C++ ACE_Handle_Set::is_set怎么用?C++ ACE_Handle_Set::is_set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ACE_Handle_Set
的用法示例。
在下文中一共展示了ACE_Handle_Set::is_set方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
int
ACE_Select_Reactor_Notify::dispatch_notifications (int &number_of_active_handles,
ACE_Handle_Set &rd_mask)
{
ACE_TRACE ("ACE_Select_Reactor_Notify::dispatch_notifications");
ACE_HANDLE const read_handle =
this->notification_pipe_.read_handle ();
if (read_handle != ACE_INVALID_HANDLE
&& rd_mask.is_set (read_handle))
{
--number_of_active_handles;
rd_mask.clr_bit (read_handle);
return this->handle_input (read_handle);
}
else
return 0;
}
示例2: ACE_TMAIN
//.........这里部分代码省略.........
optsMgr.server_accept_addr);
ACE_DEBUG((LM_DEBUG,
ACE_TEXT ("(%P|%t) Accepting connections on port %u on interface %C using %C\n"),
serverAddr.get_port_number(),
(optsMgr.server_accept_addr == INADDR_ANY) ? "INADDR_ANY" : serverAddr.get_host_addr(),
(optsMgr.test_transport_protocol == IPPROTO_SCTP) ? "IPPROTO_SCTP" : "IPPROTO_TCP"));
// this operation creates a socket, binds the specified internet
// address to it and calls listen. As this is a wrapper facade
// approach, the ACE_OS::{socket,bind,listen} calls are invoked in
// the implementation of open.
if (acceptor_socket.open(serverAddr, 1,
AF_INET,
ACE_DEFAULT_BACKLOG,
optsMgr.test_transport_protocol) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("%p\n"),
ACE_TEXT ("open")),
1);
// this function checks that the port that was actually bound was
// the port we asked for. Apparently some operating systems will
// automatically select new ports if the specified port is currently
// used.
else if (acceptor_socket.get_local_addr(serverAddr) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("%p\n"),
ACE_TEXT ("get_local_addr")),
1);
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("(%P|%t) starting server at port %d\n"),
serverAddr.get_port_number()));
// this is the stream object that will associated with a completed
// connection (aka the data mode socket). It will be set when accept
// is called below.
ACE_SOCK_Stream new_stream;
// a file decriptor set
ACE_Handle_Set handle_set;
// add the acceptor socket to the file descriptor set.
handle_set.set_bit(acceptor_socket.get_handle());
for (;;){
ACE_Time_Value timeout(ACE_DEFAULT_TIMEOUT);
ACE_Handle_Set temp = handle_set;
// wait for connect() call from client. In the original test there
// were two different acceptor sockets for two different
// services. So select was needed to wait on both sockets
// simultaneously. In this test we could just call accept on the
// one socket.
int result = ACE_OS::select(ACE_Utils::truncate_cast<int> ((intptr_t)acceptor_socket.get_handle()) +1,
(fd_set *) temp,
0,
0,
timeout);
// check that select did not end with an error.
if (result == -1)
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("(%P|%t) %p\n"),
ACE_TEXT ("select")));
// check to see if select timed out.
else if (result == 0){
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("(%P|%t) select timed out\n")));
}
else { // case where a file descriptor was actually set
if (!(temp.is_set(acceptor_socket.get_handle()))){
// CANNOT BE REACHED
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("(%P|%t) %p\n"),
ACE_TEXT ("select: NO ERROR BUT NO FD SET")));
} else {
// call accept to set up the new stream.
if (acceptor_socket.accept(new_stream) == -1) {
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("%p\n"),
ACE_TEXT ("accept")));
continue;
}
else{
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("(%P|%t) spawning server\n")));
}
// Run the server.
run_server (new_stream.get_handle ());
}
}
}
ACE_NOTREACHED (return 0;)
}
示例3: timeout
int
ACE_TMAIN(int argc, ACE_TCHAR* argv[]){
u_long priority_mask =
ACE_LOG_MSG->priority_mask (ACE_Log_Msg::PROCESS);
ACE_CLR_BITS (priority_mask,
LM_DEBUG|LM_TRACE);
ACE_LOG_MSG->priority_mask (priority_mask,
ACE_Log_Msg::PROCESS);
ACE::set_handle_limit();
ACE_Thread_Manager* mgr = ACE_Thread_Manager::instance();
ACE_SOCK_Acceptor _987acceptor;
ACE_INET_Addr _987addr(0x987);//2439
if(_987acceptor.open(_987addr, 1) == -1){
ACE_ERROR_RETURN((LM_ERROR,
"%p\n",
"open"),
1);
}else if(_987acceptor.get_local_addr(_987addr) == -1){
ACE_ERROR_RETURN ((LM_ERROR,
"%p\n",
"get_local_addr"),
1);
}
ACE_DEBUG((LM_INFO,
"(%P|%t) starting 987 server at port %d\n",
_987addr.get_port_number()));
ACE_SOCK_Stream _str;
ACE_Handle_Set _set;
_set.set_bit(_987acceptor.get_handle());
do{
ACE_Time_Value timeout(ACE_DEFAULT_TIMEOUT);
ACE_Handle_Set tmp = _set;
int result = ACE_OS::select(ACE_Utils::truncate_cast<int> ((intptr_t) _987acceptor.get_handle()) +1,
(fd_set *) tmp,
0,
0,
NULL);
if(result == -1)
ACE_ERROR((LM_ERROR,
"(%P|%t) %p\n",
"select"));
else if(result==0)
ACE_DEBUG((LM_INFO,
"(%P|%t) select timed out\n"));
else{
if(tmp.is_set(_987acceptor.get_handle())){
if(_987acceptor.accept(_str) == -1){
ACE_ERROR((LM_ERROR,
"%p\n",
"987 accept"));
continue;
}else{
ACE_DEBUG((LM_INFO,
"(%P|%t: %l) spawning 987 server\n"));
if(mgr->spawn(process,
reinterpret_cast<void*> (_str.get_handle()),
THR_DETACHED) == -1){
ACE_ERROR((LM_ERROR,
"(%P|%t) %p\n",
"spawn"));
}
}
}
}
}while(true);
return 0;
}
示例4: twoway_server_addr
static int
run_event_loop (u_short port)
{
// Raise the socket handle limit to the maximum.
ACE::set_handle_limit ();
// Create the oneway and twoway acceptors.
ACE_SSL_SOCK_Acceptor twoway_acceptor;
ACE_SSL_SOCK_Acceptor oneway_acceptor;
// Create the oneway and twoway server addresses.
ACE_INET_Addr twoway_server_addr (port);
ACE_INET_Addr oneway_server_addr (port + 1);
// Create acceptors, reuse the address.
if (twoway_acceptor.open (twoway_server_addr, 1) == -1
|| oneway_acceptor.open (oneway_server_addr, 1) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
"%p\n",
"open"),
1);
else if (twoway_acceptor.get_local_addr (twoway_server_addr) == -1
|| oneway_acceptor.get_local_addr (oneway_server_addr) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
"%p\n",
"get_local_addr"),
1);
ACE_DEBUG ((LM_DEBUG,
"(%P|%t) starting twoway server at port %d and oneway server at port %d\n",
twoway_server_addr.get_port_number (),
oneway_server_addr.get_port_number ()));
// Keep these objects out here to prevent excessive constructor
// calls within the loop.
ACE_SSL_SOCK_Stream new_stream;
ACE_Handle_Set handle_set;
handle_set.set_bit (twoway_acceptor.get_handle ());
handle_set.set_bit (oneway_acceptor.get_handle ());
// Performs the iterative server activities.
for (;;)
{
ACE_Time_Value timeout (ACE_DEFAULT_TIMEOUT);
ACE_Handle_Set temp = handle_set;
int maxfd = int(oneway_acceptor.get_handle ());
if (maxfd < int(twoway_acceptor.get_handle ()))
maxfd = int(twoway_acceptor.get_handle ());
int result = ACE_OS::select (maxfd + 1,
(fd_set *) temp,
0,
0,
timeout);
if (result == -1)
ACE_ERROR ((LM_ERROR,
"(%P|%t) %p\n",
"select"));
else if (result == 0 && verbose)
ACE_DEBUG ((LM_DEBUG,
"(%P|%t) select timed out\n"));
else
{
if (temp.is_set (twoway_acceptor.get_handle ()))
{
int r = twoway_acceptor.accept (new_stream);
while (r == -1 && errno == EAGAIN)
r = twoway_acceptor.accept (new_stream);
if (r == -1)
{
ACE_ERROR ((LM_ERROR,
"%p\n",
"accept"));
continue;
}
else
ACE_DEBUG ((LM_DEBUG,
"(%P|%t) spawning twoway server\n"));
// Run the twoway server.
twoway_server (new_stream);
}
if (temp.is_set (oneway_acceptor.get_handle ()))
{
if (oneway_acceptor.accept (new_stream) == -1)
{
ACE_ERROR ((LM_ERROR, "%p\n", "accept"));
continue;
}
else
ACE_DEBUG ((LM_DEBUG,
"(%P|%t) spawning oneway server\n"));
// Run the oneway server.
oneway_server (new_stream);
}
}
}
//.........这里部分代码省略.........
示例5: twoway_server_addr
static int
run_event_loop (u_short port)
{
// Raise the socket handle limit to the maximum.
ACE::set_handle_limit ();
// Create the oneway and twoway acceptors.
ACE_SSL_SOCK_Acceptor twoway_acceptor;
ACE_SSL_SOCK_Acceptor oneway_acceptor;
// Create the oneway and twoway server addresses.
ACE_INET_Addr twoway_server_addr (port);
ACE_INET_Addr oneway_server_addr (port + 1);
// Create acceptors, reuse the address.
if (twoway_acceptor.open (twoway_server_addr, 1) == -1
|| oneway_acceptor.open (oneway_server_addr, 1) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
"%p\n",
"open"),
1);
else if (twoway_acceptor.get_local_addr (twoway_server_addr) == -1
|| oneway_acceptor.get_local_addr (oneway_server_addr) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
"%p\n",
"get_local_addr"),
1);
ACE_DEBUG ((LM_DEBUG,
"(%P|%t) starting twoway server at port %d and oneway server at port %d\n",
twoway_server_addr.get_port_number (),
oneway_server_addr.get_port_number ()));
// Keep these objects out here to prevent excessive constructor
// calls within the loop.
ACE_Handle_Set handle_set;
handle_set.set_bit (twoway_acceptor.get_handle ());
handle_set.set_bit (oneway_acceptor.get_handle ());
ACE_SSL_SOCK_Stream * new_stream = 0;
// Performs the iterative server activities.
for (;;)
{
ACE_Time_Value timeout (ACE_DEFAULT_TIMEOUT);
ACE_Handle_Set temp = handle_set;
int result = ACE_OS::select (int (oneway_acceptor.get_handle ()) + 1,
(fd_set *) temp,
0,
0,
timeout);
if (result == -1)
ACE_ERROR ((LM_ERROR,
"(%P|%t) %p\n",
"select"));
else if (result == 0 && verbose)
ACE_DEBUG ((LM_DEBUG,
"(%P|%t) select timed out\n"));
else
{
// A new ACE_SSL_SOCK_Stream must be initialized for each
// connection. However, it retains (SSL) state so simply
// initializing a new ACE_SSL_SOCK_Stream by passing it a
// handle isn't enough, nor is it allowed. Such a scheme is
// is sometimes done with the non-SSL aware
// ACE_SOCK_Stream. An ACE_SSL_SOCK_Stream should only be
// initialized by an ACE_SSL_SOCK_Acceptor (server side), or an
// ACE_SSL_SOCK_Connector (client side).
//
// It is also possible to copy or assign an
// ACE_SSL_SOCK_Stream since it implements both
// methods/operators. However, the user must ensure that
// the copy or assignment is atomic.
if (temp.is_set (twoway_acceptor.get_handle ()))
{
ACE_NEW_RETURN (new_stream,
ACE_SSL_SOCK_Stream,
-1);
if (twoway_acceptor.accept (*new_stream) == -1)
{
ACE_ERROR ((LM_ERROR,
"%p\n",
"accept"));
delete new_stream;
continue;
}
else
ACE_DEBUG ((LM_DEBUG,
"(%P|%t) spawning twoway server\n"));
// Run the twoway server.
run_server (twoway_server,
new_stream);
}
//.........这里部分代码省略.........