summaryrefslogtreecommitdiff
path: root/docs/tutorials/015/page20.html
blob: 3f604e11bfa50f2981d2ffd2fab8130d867aec40 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<!-- $Id$ -->
<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%">
While I might be able to come up with a competitive compressor, I
don't have a snowball's chance to code up encryption.  I'd be better
off piping the data through the standard Unix crypt command.
<P>
So, while I was lazy with Compress, I'm realistic with Crypt.  I'll
show you the hooks and entry points and let someone else contribute an
encryptor.
<HR>
<PRE>
<font color=red>// $Id$</font>

<font color=blue>#ifndef</font> <font color=purple>CRYPT_H</font>
<font color=blue>#define</font> <font color=purple>CRYPT_h</font>

<font color=blue>#include</font> "<font color=green>Protocol_Task.h</font>"

<font color=red>/* An interface (adaptor) between your favorite encryption method and
   an ACE_Stream.
*/</font>
class Crypt : public Protocol_Task
{
public:

  typedef Protocol_Task inherited;

  Crypt (void);

  ~Crypt (void);

protected:

  <font color=red>// Moving downstream will encrypt the data</font>
  int send (ACE_Message_Block *message,
            ACE_Time_Value *timeout);

  <font color=red>// And moving upstream will decrypt it.</font>
  int recv (ACE_Message_Block *message,
            ACE_Time_Value *timeout);
};

<font color=blue>#endif</font> <font color=red>/* CRYPT_H */</font>
</PRE>
<P><HR WIDTH="100%">
<CENTER>[<A HREF="../online-tutorials.html">Tutorial Index</A>] [<A HREF="page21.html">Continue This Tutorial</A>]</CENTER>