diff options
author | Steve Huston <shuston@riverace.com> | 1999-02-16 23:57:48 +0000 |
---|---|---|
committer | Steve Huston <shuston@riverace.com> | 1999-02-16 23:57:48 +0000 |
commit | cbef364f1d1f1a053dd05fa758efedde41a9b294 (patch) | |
tree | 9e28bd331f7da5df0a600ada884e7b49386db474 /examples | |
parent | a56449b7135ca2096fcc0d24f4e3357ad3c5a4d3 (diff) | |
download | ATCD-cbef364f1d1f1a053dd05fa758efedde41a9b294.tar.gz |
Moved class defs needed for auto template instantiate to new file, test_upipe.h
Diffstat (limited to 'examples')
-rw-r--r-- | examples/Connection/misc/test_upipe.cpp | 62 | ||||
-rw-r--r-- | examples/Connection/misc/test_upipe.h | 75 |
2 files changed, 76 insertions, 61 deletions
diff --git a/examples/Connection/misc/test_upipe.cpp b/examples/Connection/misc/test_upipe.cpp index 147ea4a8f1e..f6fbc5c1dda 100644 --- a/examples/Connection/misc/test_upipe.cpp +++ b/examples/Connection/misc/test_upipe.cpp @@ -15,35 +15,7 @@ ACE_RCSID(misc, test_upipe, "$Id$") #if defined (ACE_HAS_THREADS) -typedef ACE_Svc_Handler <ACE_UPIPE_STREAM, ACE_NULL_SYNCH> SVC_HANDLER; - -class Server_Service : public SVC_HANDLER - // = TITLE - // Defines the interface for a service that recvs data from its - // client and writes the data to its stdout. -{ -public: - Server_Service (ACE_Thread_Manager * = 0) {} - - virtual int open (void *) - { - ACE_TRACE ("Server_Service::open"); - return 0; - } - - virtual int svc (void) - { - ACE_TRACE ("Server_Service::svc"); - - char buf[BUFSIZ]; - ssize_t n; - - while ((n = this->peer ().recv (buf, sizeof buf)) > 0) - ::write (1, buf, n); - - return 0; - } -}; +#include "test_upipe.h" class Server : public ACE_Strategy_Acceptor <Server_Service, ACE_UPIPE_ACCEPTOR> // = TITLE @@ -88,38 +60,6 @@ private: // Our concurrency strategy. }; -class Client_Service : public SVC_HANDLER - // = TITLE - // Defines the interface for a service that recvs data from its - // stdin and forward the data to its server. -{ -public: - Client_Service (ACE_Thread_Manager *thr_mgr = 0) - : SVC_HANDLER (thr_mgr) - { - ACE_TRACE ("Client_Service::Client_Service"); - } - - virtual int open (void *) - { - ACE_TRACE ("Client_Service::open"); - return this->activate (THR_DETACHED | THR_NEW_LWP); - } - - virtual int svc (void) - { - ACE_TRACE ("Client_Service::svc"); - char buf[BUFSIZ]; - ssize_t n; - - while ((n = ACE_OS::read (ACE_STDIN, buf, sizeof buf)) > 0) - this->peer ().send (buf, n); - - this->peer ().close (); - return 0; - } -}; - class Client : public ACE_Connector <Client_Service, ACE_UPIPE_CONNECTOR> // = TITLE // Defines the interface for a factory that connects diff --git a/examples/Connection/misc/test_upipe.h b/examples/Connection/misc/test_upipe.h new file mode 100644 index 00000000000..edc502a7a43 --- /dev/null +++ b/examples/Connection/misc/test_upipe.h @@ -0,0 +1,75 @@ +/* -*- C++ -*- */ + +// $Id$ + +#ifndef ACE_TEST_UPIPE_H +#define ACE_TEST_UPIPE_H + +#include "ace/Svc_Handler.h" +#include "ace/Synch.h" +#include "ace/UPIPE_Stream.h" + +typedef ACE_Svc_Handler <ACE_UPIPE_STREAM, ACE_NULL_SYNCH> SVC_HANDLER; + +class Server_Service : public SVC_HANDLER + // = TITLE + // Defines the interface for a service that recvs data from its + // client and writes the data to its stdout. +{ +public: + Server_Service (ACE_Thread_Manager * = 0) {} + + virtual int open (void *) + { + ACE_TRACE ("Server_Service::open"); + return 0; + } + + virtual int svc (void) + { + ACE_TRACE ("Server_Service::svc"); + + char buf[BUFSIZ]; + ssize_t n; + + while ((n = this->peer ().recv (buf, sizeof buf)) > 0) + ::write (1, buf, n); + + return 0; + } +}; + + +class Client_Service : public SVC_HANDLER + // = TITLE + // Defines the interface for a service that recvs data from its + // stdin and forward the data to its server. +{ +public: + Client_Service (ACE_Thread_Manager *thr_mgr = 0) + : SVC_HANDLER (thr_mgr) + { + ACE_TRACE ("Client_Service::Client_Service"); + } + + virtual int open (void *) + { + ACE_TRACE ("Client_Service::open"); + return this->activate (THR_DETACHED | THR_NEW_LWP); + } + + virtual int svc (void) + { + ACE_TRACE ("Client_Service::svc"); + char buf[BUFSIZ]; + ssize_t n; + + while ((n = ACE_OS::read (ACE_STDIN, buf, sizeof buf)) > 0) + this->peer ().send (buf, n); + + this->peer ().close (); + return 0; + } +}; + +#endif /* ACE_TEST_UPIPE_H */ |