blob: 6f81ebfa5ec3393f120cc5b3cc49cffae9d97dba (
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
60
61
|
<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;
<font color=red>// Again we have the option of multiple threads and again I</font>
<font color=red>// regret tempting folks to use it.</font>
Crypt( int _thr_count = 0 );
~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="..">Tutorial Index</A>] [<A HREF="page21.html">Continue This Tutorial</A>]</CENTER>
|