diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1997-05-05 22:34:06 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1997-05-05 22:34:06 +0000 |
commit | 667aab398a22c7c53f234321f1a560cb6d5a5b28 (patch) | |
tree | a07cc5b1199793565c432d915b0ae2c1aa216ed8 /examples | |
parent | ff5e209d07484d64c73f63ad552408e981274c90 (diff) | |
download | ATCD-667aab398a22c7c53f234321f1a560cb6d5a5b28.tar.gz |
*** empty log message ***
Diffstat (limited to 'examples')
-rw-r--r-- | examples/ASX/Event_Server/Transceiver/transceiver.cpp | 40 | ||||
-rw-r--r-- | examples/Misc/test_set.cpp | 50 |
2 files changed, 29 insertions, 61 deletions
diff --git a/examples/ASX/Event_Server/Transceiver/transceiver.cpp b/examples/ASX/Event_Server/Transceiver/transceiver.cpp index 4c9a16abaf0..d86e4ee2d9a 100644 --- a/examples/ASX/Event_Server/Transceiver/transceiver.cpp +++ b/examples/ASX/Event_Server/Transceiver/transceiver.cpp @@ -67,6 +67,7 @@ class Event_Transceiver : public ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH // it is a ``transceiver.'' { public: + // = Initialization method. Event_Transceiver (void); // = Svc_Handler hook called by the <ACE_Connector>. @@ -99,12 +100,12 @@ Event_Transceiver::handle_close (ACE_HANDLE, return 0; } -// Close down via SIGINT. +// Close down via SIGINT or SIGQUIT. int Event_Transceiver::handle_signal (int signum, - siginfo_t *, - ucontext_t *) + siginfo_t *, + ucontext_t *) { ACE_DEBUG ((LM_DEBUG, "(%P|%t) received signal %S\n", signum)); @@ -117,24 +118,37 @@ Event_Transceiver::Event_Transceiver (void) ACE_Sig_Set sig_set; sig_set.sig_add (SIGINT); + +#if !defined (ACE_WIN32) sig_set.sig_add (SIGQUIT); +#endif /* ACE_WIN32 */ if (ACE_Service_Config::reactor ()->register_handler (sig_set, this) == -1) ACE_ERROR ((LM_ERROR, "%p\n", "register_handler")); + + // We need to register <this> here before we're connected since + // otherwise <get_handle> will return the connection socket handle + // for the peer. + else if (ACE::register_stdin_handler (this, + ACE_Service_Config::reactor (), + ACE_Service_Config::thr_mgr ()) == -1) + ACE_ERROR ((LM_ERROR, + "%p\n", + "register_stdin_handler")); } int Event_Transceiver::open (void *) { + // Register ourselves to be notified when there's data on the + // socket. if (ACE_Service_Config::reactor ()->register_handler - (this->peer ().get_handle (), this, - ACE_Event_Handler::READ_MASK) == -1) - ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "register_handler"), -1); - else if (ACE::register_stdin_handler (this, - ACE_Service_Config::reactor (), - ACE_Service_Config::thr_mgr ()) == -1) - ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "register_stdin_handler"), -1); + (this, ACE_Event_Handler::READ_MASK) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + "%p\n", + "register_handler"), + -1); return 0; } @@ -192,11 +206,13 @@ main (int argc, char *argv[]) parse_args (argc, argv); - // Establish the connection. ACE_Connector<Event_Transceiver, ACE_SOCK_CONNECTOR> connector; Event_Transceiver transceiver, *tp = &transceiver; - if (connector.connect (tp, ACE_INET_Addr (port_number, host_name)) == -1) + ACE_INET_Addr server_addr (port_number, host_name); + + // Establish the connection to the Event Server. + if (connector.connect (tp, server_addr) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", host_name), 1); // Run event loop until either the event server shuts down or we get diff --git a/examples/Misc/test_set.cpp b/examples/Misc/test_set.cpp index d6ff912e604..e43d96bab82 100644 --- a/examples/Misc/test_set.cpp +++ b/examples/Misc/test_set.cpp @@ -1,60 +1,12 @@ // $Id$ -#include "ace/Set.h" +#include "ace/Containers.h" int main (int, char *[]) { - ACE_Unbounded_Set<int> s1; - - ACE_ASSERT (s1.size () == 0); - s1.insert_tail (10); - s1.insert_tail (20); - ACE_ASSERT (s1.size () == 2); - - ACE_Unbounded_Set<int> s2 (s1); - ACE_ASSERT (s2.size () == 2); - - ACE_Unbounded_Set<int> s3; - ACE_ASSERT (s3.size () == 0); - - s3 = s2; - ACE_ASSERT (s3.size () == s2.size ()); - - ACE_Unbounded_Set<int> s4 (s3); - ACE_ASSERT (s4.size () == 2); - - int *ip = 0; - - ACE_DEBUG ((LM_DEBUG, "dumping s1\n")); - for (ACE_Unbounded_Set_Iterator<int> iter1 (s1); - iter1.next (ip) != 0; - iter1.advance ()) - ACE_DEBUG ((LM_DEBUG, "item = %d\n", *ip)); - - ACE_DEBUG ((LM_DEBUG, "dumping s2\n")); - for (ACE_Unbounded_Set_Iterator<int> iter2 (s2); - iter2.next (ip) != 0; - iter2.advance ()) - ACE_DEBUG ((LM_DEBUG, "item = %d\n", *ip)); - - ACE_DEBUG ((LM_DEBUG, "dumping s3\n")); - for (ACE_Unbounded_Set_Iterator<int> iter3 (s3); - iter3.next (ip) != 0; - iter3.advance ()) - ACE_DEBUG ((LM_DEBUG, "item = %d\n", *ip)); - - ACE_DEBUG ((LM_DEBUG, "dumping s4\n")); - for (ACE_Unbounded_Set_Iterator<int> iter4 (s4); - iter4.next (ip) != 0; - iter4.advance ()) - ACE_DEBUG ((LM_DEBUG, "item = %d\n", *ip)); - return 0; } #if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) -template class ACE_Unbounded_Set<int>; -template class ACE_Unbounded_Set_Iterator<int>; -template class ACE_Set_Node<int>; #endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ |