summaryrefslogtreecommitdiff
path: root/docs/tutorials/002/page03.html
blob: 38ed438ed18c64a8d0e47c7044f7e07b2eb9d67a (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
62
63
64
65
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
   <TITLE>ACE Tutorial 002</TITLE>
   <META NAME="GENERATOR" CONTENT="Mozilla/3.01Gold (Win95; I) [Netscape]">
   <META NAME="Author" CONTENT="James CE Johnson">
   <META NAME="Description" CONTENT="A first step towards using ACE productively">
</HEAD>
<BODY text = "#000000" link="#000fff" vlink="#ff0f0f" bgcolor="#ffffff">


<CENTER><P><B><FONT SIZE=+2>ACE&nbsp;Tutorial 002<BR>
Creating a Better Server </FONT></B></P></CENTER>

<P>
<HR WIDTH="100%"></P>

<P>This is what we do to create an acceptor from the ACE&nbsp;template:</P>

<UL>
<PRE>        
1.      #include &quot;ace/Acceptor.h&quot;
2.      #include &quot;ace/SOCK_Acceptor.h&quot;
        
3.      typedef ACE_Acceptor &lt;Logging_Handler, ACE_SOCK_ACCEPTOR&gt; Logging_Acceptor;
</PRE>
</UL>

<P>
<HR></P>

<P>Now, if you think that was difficult, you may as well give up now.</P>

<OL>
<LI>The <I>Acceptor</I> header file defines the template we're about to
use. This is a totally generic object where all of the hard work as already
been done.</LI>

<LI>Because we want to accept connections on an <I>ACE_SOCK_Stream</I>,
we have to pull in this header. It provides the API details that we will
need.</LI>

<LI>Finally, create a <I>Logging_Acceptor</I> object based on the <I>ACE_Acceptor</I>
template. The first parameter <I>Logging_Handler</I> is an object we will
develop on the next page. This object will be created by the template-generated
code whenever a new connection request is accepted. The second parameter
tells the template what kind of acceptor to create. It is most important
that the first-parameter object and the second parameter be consistent
in the connetion types used.</LI>
</OL>

<P>Obviously we're doing things a bit out of order here: <I>main</I> won't
be happy until it knows what a <I>Logging_Acceptor</I> is and the acceptor
won't be happy until it knows what a <I>Logging_Handler</I> is. The next
page pulls in this last definition for us and after that we tie it all
together.</P>

<P>
<HR WIDTH="100%"></P>

<CENTER><P>[<A HREF="../../Tutorial">Tutorial Index</A>] [<A HREF="page02.html">Previous
Page</A>] [<A HREF="page04.html">Continue This Tutorial</A>] </P></CENTER>

</BODY>
</HTML>