diff options
author | levine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2000-02-16 03:34:00 +0000 |
---|---|---|
committer | levine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2000-02-16 03:34:00 +0000 |
commit | 07cea526f7e3e52257870795c9df760e8433d194 (patch) | |
tree | 4855291241ae2e5f0b6a6f686b49e01587690eba /examples | |
parent | c0dd29e2b6e77482ec37fee5db08ccff4b5872ae (diff) | |
download | ATCD-07cea526f7e3e52257870795c9df760e8433d194.tar.gz |
ChangeLogTag: Tue Feb 15 21:26:00 2000 David L. Levine <levine@cs.wustl.edu>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/IPC_SAP/SOCK_SAP/CPP-unserver.cpp | 31 | ||||
-rw-r--r-- | examples/IPC_SAP/SOCK_SAP/FD-unserver.cpp | 66 | ||||
-rw-r--r-- | examples/Reactor/Multicast/server.cpp | 51 |
3 files changed, 73 insertions, 75 deletions
diff --git a/examples/IPC_SAP/SOCK_SAP/CPP-unserver.cpp b/examples/IPC_SAP/SOCK_SAP/CPP-unserver.cpp index 3f65dfce07d..fc79d149fe9 100644 --- a/examples/IPC_SAP/SOCK_SAP/CPP-unserver.cpp +++ b/examples/IPC_SAP/SOCK_SAP/CPP-unserver.cpp @@ -4,7 +4,7 @@ // ACE_LSOCK_Stream classes. If the platform supports threads it uses // a thread-per-request concurrency model. -#include "ace/LSOCK_Acceptor.h" +#include "ace/LSOCK_Acceptor.h" #include "ace/Thread_Manager.h" ACE_RCSID(SOCK_SAP, CPP_unserver, "$Id$") @@ -31,14 +31,14 @@ server (void *arg) "%p\n", "disable"), 0); - + if (new_stream.get_remote_addr (cli_addr) == -1) ACE_ERROR ((LM_ERROR, "%p\n", "get_remote_addr")); ACE_DEBUG ((LM_DEBUG, - "(%P|%t) client connected from %s\n", + "(%P|%t) client connected from %s\n", cli_addr.get_path_name ())); // Read data from client (terminate on error). @@ -106,12 +106,12 @@ run_event_loop (const char rendezvous[]) -1); ACE_DEBUG ((LM_DEBUG, - "starting server %s\n", + "starting server %s\n", server_addr.get_path_name ())); // Keep these guys out here to prevent excessive constructor // calls... - ACE_LSOCK_Stream new_stream; + ACE_LSOCK_Stream new_stream; // Performs the iterative server activities. @@ -120,12 +120,12 @@ run_event_loop (const char rendezvous[]) ACE_Time_Value timeout (ACE_DEFAULT_TIMEOUT); if (peer_acceptor.accept (new_stream, 0, &timeout) == -1) - { - ACE_ERROR ((LM_ERROR, + { + ACE_ERROR ((LM_ERROR, "%p\n", "accept")); - continue; - } + continue; + } #if defined (ACE_HAS_THREADS) if (ACE_Thread_Manager::instance ()->spawn ((ACE_THR_FUNC) server, @@ -138,21 +138,20 @@ run_event_loop (const char rendezvous[]) #else server ((void *) new_stream.get_handle ()); #endif /* ACE_HAS_THREADS */ - } + } - /* NOTREACHED */ - return 0; + ACE_NOTREACHED (return 0;) } -int +int main (int argc, char *argv[]) -{ +{ return run_event_loop (argc > 1 ? argv[1] : ACE_DEFAULT_RENDEZVOUS); } #else int main (int, char *[]) { - ACE_ERROR_RETURN ((LM_ERROR, - "this platform does not support UNIX-domain sockets\n"), -1); + ACE_ERROR_RETURN ((LM_ERROR, + "this platform does not support UNIX-domain sockets\n"), -1); } #endif /* ACE_LACKS_UNIX_DOMAIN_SOCKETS */ diff --git a/examples/IPC_SAP/SOCK_SAP/FD-unserver.cpp b/examples/IPC_SAP/SOCK_SAP/FD-unserver.cpp index ae87537fd99..99934458e3e 100644 --- a/examples/IPC_SAP/SOCK_SAP/FD-unserver.cpp +++ b/examples/IPC_SAP/SOCK_SAP/FD-unserver.cpp @@ -1,8 +1,8 @@ // $Id$ -#include "ace/LSOCK_Acceptor.h" +#include "ace/LSOCK_Acceptor.h" #include "ace/LSOCK_Stream.h" -#include "ace/UNIX_Addr.h" +#include "ace/UNIX_Addr.h" ACE_RCSID(SOCK_SAP, FD_unserver, "$Id$") @@ -20,70 +20,70 @@ handle_client (ACE_LSOCK_Stream &stream) if (stream.recv_handle (handle) == -1) ACE_ERROR ((LM_ERROR, "%p", "recv_handle")); - + ACE_DEBUG ((LM_DEBUG, "(%P|%t) ----------------------------------------\n")); - + // Read data from client (correctly handles incomplete reads due to // flow control). - - for (ssize_t n; - (n = ACE_OS::read (handle, buf, sizeof buf)) > 0; + + for (ssize_t n; + (n = ACE_OS::read (handle, buf, sizeof buf)) > 0; ) ACE_DEBUG ((LM_DEBUG, "%*s", n, buf)); - + ACE_OS::sprintf (buf, "%ld", ACE_OS::getpid ()); - + ACE_DEBUG ((LM_DEBUG, "(%s, %d) ----------------------------------------\n", buf, ACE_OS::strlen (buf))); - + // Tell the client to shut down. if (stream.send_n (buf, ACE_OS::strlen (buf)) == -1) ACE_ERROR ((LM_ERROR, "%p", "send")); - + // Close new endpoint (listening endpoint stays open). - if (stream.close () == -1) + if (stream.close () == -1) ACE_ERROR ((LM_ERROR, "%p", "close")); } -int +int main (int argc, char *argv[]) -{ +{ const char *rendezvous = argc > 1 ? argv[1] : ACE_DEFAULT_RENDEZVOUS; // Create a server. ACE_OS::unlink (rendezvous); ACE_UNIX_Addr addr (rendezvous); ACE_LSOCK_Acceptor peer_acceptor (addr); ACE_LSOCK_Stream stream; - + // Performs the concurrent server activities. - - for (;;) + + for (;;) { // Create a new ACE_SOCK_Stream endpoint. if (peer_acceptor.accept (stream) == -1) - ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) %p\n", "accept"), -1); + ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) %p\n", "accept"), -1); ACE_DEBUG ((LM_DEBUG, "(%P|%t) accepted new connection\n")); - + #if defined (VXWORKS) handle_client (stream); #else switch (ACE_OS::fork (argv[0])) - { - case -1: - ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) %p\n", "fork"), -1); - /* NOTREACHED */ - case 0: - ACE_LOG_MSG->sync (argv[0]); - handle_client (stream); - ACE_OS::exit (0); - /* NOTREACHED */ - default: - stream.close (); - } + { + case -1: + ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) %p\n", "fork"), -1); + /* NOTREACHED */ + case 0: + ACE_LOG_MSG->sync (argv[0]); + handle_client (stream); + ACE_OS::exit (0); + /* NOTREACHED */ + default: + stream.close (); + } #endif /* VXWORKS */ } - /* NOTREACHED */ - return 0; + + ACE_NOTREACHED (return 0;) } #else int diff --git a/examples/Reactor/Multicast/server.cpp b/examples/Reactor/Multicast/server.cpp index 569cfe96b1e..a3630d71a1e 100644 --- a/examples/Reactor/Multicast/server.cpp +++ b/examples/Reactor/Multicast/server.cpp @@ -18,13 +18,13 @@ class Server_Events : public ACE_Event_Handler { public: Server_Events (u_short port, - const char *mcast_addr, - long time_interval = 0); + const char *mcast_addr, + long time_interval = 0); ~Server_Events (void); virtual int handle_input (ACE_HANDLE fd); virtual int handle_timeout (const ACE_Time_Value &tv, - const void *arg); + const void *arg); virtual ACE_HANDLE get_handle (void) const; @@ -103,16 +103,16 @@ Server_Events::~Server_Events (void) this->mcast_dgram_.unsubscribe (); ACE_DEBUG ((LM_DEBUG, "total bytes received = %d after %d second\n", - this->total_bytes_received_, this->interval_)); + this->total_bytes_received_, this->interval_)); ACE_DEBUG ((LM_DEBUG, "Mbits/sec = %.2f\n", - (float) (total_bytes_received_ * 8 / (float) (1024*1024*interval_)))); + (float) (total_bytes_received_ * 8 / (float) (1024*1024*interval_)))); ACE_DEBUG ((LM_DEBUG, - "last sequence number = %d\ntotal messages received = %d\ndiff = %d\n", - this->last_sequence_number_, - this->total_messages_received_, - this->last_sequence_number_ - total_messages_received_)); + "last sequence number = %d\ntotal messages received = %d\ndiff = %d\n", + this->last_sequence_number_, + this->total_messages_received_, + this->last_sequence_number_ - total_messages_received_)); } int @@ -120,9 +120,9 @@ Server_Events::handle_timeout (const ACE_Time_Value &, const void *arg) { ACE_DEBUG ((LM_DEBUG, "\t%d timeout%s occurred for %s.\n", - this->count_, - this->count_ == 1 ? "" : "s", - (char *) arg)); + this->count_, + this->count_ == 1 ? "" : "s", + (char *) arg)); // Don't let the timeouts continue if there's no activity since // otherwise we use up a lot of CPU time unnecessarily. @@ -132,8 +132,8 @@ Server_Events::handle_timeout (const ACE_Time_Value &, this->initialized_ = 0; ACE_DEBUG ((LM_DEBUG, - "\tcancelled timeout for %s to avoid busy waiting.\n", - (char *) arg)); + "\tcancelled timeout for %s to avoid busy waiting.\n", + (char *) arg)); } this->count_++; @@ -160,19 +160,19 @@ Server_Events::handle_input (ACE_HANDLE) last_sequence_number_ = ntohl (log_record_->sequence_number); ACE_DEBUG ((LM_DEBUG, "sequence number = %d\n", - last_sequence_number_)); + last_sequence_number_)); ACE_DEBUG ((LM_DEBUG, "message = '%s'\n", - this->message_)); + this->message_)); if (this->initialized_ == 0) { - // Restart the timer since we've received events again. - if (reactor()->schedule_timer (this, - (void *) this->hostname_, - ACE_Time_Value::zero, - ACE_Time_Value (DURATION)) == -1) - ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "schedule_timer"), -1); - this->initialized_ = 1; + // Restart the timer since we've received events again. + if (reactor()->schedule_timer (this, + (void *) this->hostname_, + ACE_Time_Value::zero, + ACE_Time_Value (DURATION)) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "schedule_timer"), -1); + this->initialized_ = 1; } this->count_ = 1; @@ -193,7 +193,7 @@ main (int, char *[]) ACE_Reactor reactor; if (reactor.register_handler (&server_events, - ACE_Event_Handler::READ_MASK) == -1) + ACE_Event_Handler::READ_MASK) == -1) ACE_ERROR ((LM_ERROR, "%p\n%a", "register_handler", 1)); ACE_DEBUG ((LM_DEBUG, "starting up server\n")); @@ -201,8 +201,7 @@ main (int, char *[]) for (;;) reactor.handle_events (server_events.wait_time ()); - /* NOTREACHED */ - return 0; + ACE_NOTREACHED (return 0;) } #else int |