diff options
Diffstat (limited to 'docs/tutorials/015/page18.html')
-rw-r--r-- | docs/tutorials/015/page18.html | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/docs/tutorials/015/page18.html b/docs/tutorials/015/page18.html new file mode 100644 index 00000000000..7f5603946b8 --- /dev/null +++ b/docs/tutorials/015/page18.html @@ -0,0 +1,68 @@ +<HTML> +<HEAD> + <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> + <META NAME="Author" CONTENT="James CE Johnson"> + <TITLE>ACE Tutorial 015</TITLE> +</HEAD> +<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#000FFF" VLINK="#FF0F0F"> + +<CENTER><B><FONT SIZE=+2>ACE Tutorial 015</FONT></B></CENTER> + +<CENTER><B><FONT SIZE=+2>Building a protocol stream</FONT></B></CENTER> + +<P> +<HR WIDTH="100%"> +This and the next three pages present the protocol objects that +provide compression and encryption. If you were hoping to learn the +secrets of compression and encryption then I'm going to disappoint +you. There are some really good libraries out there that do this +stuff though and if anyone wants to integrate one of them into the +tutorial I'll be glad to take it! +<HR> +<PRE> + +<font color=red>// $Id$</font> + +<font color=blue>#ifndef</font> <font color=purple>COMPRESSOR_H</font> +<font color=blue>#define</font> <font color=purple>COMPRESSOR_h</font> + +<font color=blue>#include</font> "<font color=green>Protocol_Task.h</font>" + +<font color=red>/* A reallly dumb compression object. (It actually adds 3 bytes to + every message block.) +*/</font> +class Compressor : public Protocol_Task +{ +public: + + typedef Protocol_Task inherited; + + <font color=red>// I've given you the option of creating this task derivative</font> + <font color=red>// with a number of threads. In retro-spect that really isn't </font> + <font color=red>// a good idea. Most client/server systems rely on requests</font> + <font color=red>// and responses happening in a predicatable order. Introduce </font> + <font color=red>// a thread pool and message queue and that ordering goes</font> + <font color=red>// right out the window. In other words: Don't ever use the</font> + <font color=red>// constructor parameter!</font> + Compressor( int _thr_count = 0 ); + + ~Compressor(void); + +protected: + + <font color=red>// This is called when the compressor is on the downstream</font> + <font color=red>// side. We'll take the message, compress it and move it</font> + <font color=red>// along to the next module.</font> + int send(ACE_Message_Block *message, + ACE_Time_Value *timeout); + + <font color=red>// This one is called on the upstream side. No surprise: we</font> + <font color=red>// decompress the data and send it on up the stream.</font> + int recv(ACE_Message_Block *message, + ACE_Time_Value *timeout); +}; + +<font color=blue>#endif</font> <font color=red>// COMPRESSOR_H</font> +</PRE> +<P><HR WIDTH="100%"> +<CENTER>[<A HREF="..">Tutorial Index</A>] [<A HREF="page19.html">Continue This Tutorial</A>]</CENTER> |